Using the print Method of a ViewPrinter

You use the print method of a view printer when you want the bean to manage the print job, but you provide your own user interface.This is appropriate under the following circumstances:

How to use the print method of a view printer

To call the print method of a view printer, you create an appropriate view printer (for example, a CrosstabPrinter to print a crosstab). You create a print job, either by calling the showPrintJob method of the view printer, or by constructing a print job and then calling the setPrintJob method of the view printer to set the print job. To provide input from your user interface, you set properties on the view printer. Then you call print, to print the view. The print method must come between a startPrint and an endPrint method.

To provide input from your user interface, you set properties on the view printer before you call startPrint.

Properties that you can set on a view printer

The following table lists properties, with their descriptions. You can set these properties on the view printer to affect the way that it prints the view.

Property

Description

FitToNumPagesTall, FitToNumPagesWide

When PrintScaleType is set to SCALE_TO_FIT_PAGES, then these properties specify the number of pages on which the rows and columns should fit. You must set these properties; no default is provided.

GridlinesVisible

Specifies whether gridlines should be visible.

CustomHeaderAndFooterCallback

Specifies a callback that you can write, when you want to display different header or footer information on different printed pages of the view. For more information about this callback, see Printing Different Headers and Footers on Different Pages.

HeadersAndFootersUsingCallback

Specifies which headers and footers use a custom callback.

TopMargin, BottomMargin, LeftMargin, RightMargin

Sets the margins of the page on which the will be printed. The default for all margins is 72 pixels, or one inch.

HeaderMargin, FooterMargin

Specifies the margins between the header and footer and the edge of the page. See Specifying Headers and Footers in Printed Views.

MarginAdjustment

Specifies the behavior of the margins when a header or footer does not fit in the margin. See Specifying the Interaction of Headers, Footers, and Margins in Printed Views.

PageFormat

Specifies the PageFormat object to be used by the PageSetupDialog or the PreviewDialog.

PrintByColumns

In a table or crosstab that does not fit on one physical page, specifies whether the second physical page shows the columns to the right of the first page, or the rows below the first page. For more information, see Printing Logical Pages of Crosstabs and Tables.

PrintScaleType

Sets how to size the view for printing. By default, the view is printed at its original size.

PrintZoomFactor

When PrintScaleType is set to SCALE_TO_ZOOM_FACTOR, then this property specifies the zoom for the printed view. The default is 100 percent.

RangeType

Specifies whether to print the current logical page or a range of logical pages using the SelectedHPos property.

RepeatHeaders

In a table or crosstab that does not fit on one physical page, specifies whether the row and column headers appear on each page or only on pages that print the first row or column. Also affects the title, subtitle, footnote, and paging control, if they are visible.

ScaleFontSize

In a graph, when PrintScaleType is set to any value except ORIGINAL_SIZE, then this property specifies which text to adjust the size of in the graph.

SelectedHPos

When RangeType is set to the constant SELECTED_LOGICAL_PAGES, this property specifies the range of pages to print.

TokenSubstitution

Specifies a handler for token substitution, which makes it possible for you to insert tokens (such as a token for the current dimension member) in the headers and footers of the view printer.

The following example shows how to use the print method:

Example: Using the print Method to Print a Graph