Using the printPage Method to Take Control of a Print Job

You use the printPage method when you want complete control of the print job. When you use the printPage method, you have control over the margins, the page size, headers and footers, and the number of rows and columns to print at a time.

You might want complete control over a print job when you want to print less than a full logical page of a table or crosstab. For example, suppose that you want to print a range of cells that the user has selected. You use the printPage method to specify the rows and columns to print.

Methods and objects to use with printPage

The following tables lists the methods and their descriptions that are used with the printPage method.

View Printer Method

Description

startPrint

Sets the view for printing. Call before calling any of the other methods in this table.

setLogicalPage

Specifies the logical page to print.

setViewDimension

Specifies the size of the area in which to print the view.

calcPageBounds

Calculates the number of rows and columns that will fit into the dimension for printing the view. Call after setViewDimension and before printPage. Note: This method is not supported in a graph printer, because it is not necessary. In a graph, a logical page is always printed on a single physical page.

printPage

Prints the view to a graphics object.

endPrint

Returns the view to the state it was in before printing. Call after calling the other methods in this table.

In addition, you use the DataSubsetRecord object to specify the starting row and column for the view printer to print to a graphics object, and to get information about the last row and column that the view printer printed.

How to keep track of what has been printed

The DataSubsetRecord object stores information about the view that you are printing. The following table lists the members of the DataSubsetRecord object and their descriptions.

DataSubsetRecord Member

Description

firstColumn

You specify the first column to print.

lastColumn

The view printer (calcPageBounds method) stores the last column that will print in the specified view dimension.

firstRow
(inherited from PaginationRecord)

You specify the first row to print.

lastRow
(inherited from PaginationRecord)

The view printer (calcPageBounds method) stores the last row that will print in the specified view dimension.

x1

The horizontal position in the view to start printing from. Used when a column is too wide to fit in the specified view dimension.

x2

The horizontal position in the view where printing ended. Used when a column is too wide to fit in the specified view dimension.

needsRecalc

You set this to true if you set lastColumn, lastRow, or x2 after you call calcPageBounds but before you call printPage.

You specify the first row and column that you want to print. The calcPageBounds method of the table printer or crosstab printer stores the last column and the last row. You use the information about the last row and column in your next call to print. For example, to print the next set of columns, you use the same firstRow value as the previous call, but you set the firstColumn member to one plus the value of lastColumn.

When a column is too wide to fit in the view dimension that you have specified for printing, the calcPageBounds method sets the x2 member to the horizontal position where printing ended. In the next call, you set the x1 member to the previous value of x2.