Printing Different Headers and Footers on Different Pages

By default, the view printer prints the same headers and footers of all pages that you print; only the page number changes. If you want different headers or footers on different pages, you can provide a customized callback for header and footer text. The callback must implement the CustomHeaderAndFooterCallback interface, which is defined in the oracle.dss.dataView package. You register the callback by calling the setCustomHeaderAndFooterCallback method of the view printer.

The CustomHeaderAndFooterCallback interface has one method in it, getDynamicContent. The view printer calls getDynamicContent for each header or footer that uses a custom callback, for each page. The view printer passes the constant that identifies the header or footer, the current content of the header or footer, the physical page number, and an array that identifies the logical page. Your implementation of getDynamicContent should return the content that you want in that header or footer.

You specify which headers and footers use the custom callback by calling the setHeadersAndFootersUsingCallback method of the view printer. The following table shows the constants that this method takes, with a description of each. Use the or operator (|) to combine constants.

Constants for HeadersAndFootersUsingCallback

Description

ViewPrinter.HEADER_LEFT

Left header

ViewPrinter.HEADER_CENTER

Center header

ViewPrinter.HEADER_RIGHT

Right header

ViewPrinter.FOOTER_LEFT

Left footer

ViewPrinter.FOOTER_CENTER

Center footer

ViewPrinter.FOOTER_RIGHT

Right footer

ViewPrinter.HEADERS_AND_FOOTERS_ALL

All headers and footers

ViewPrinter.HEADERS_AND_FOOTERS_NONE

No headers and footers use a callback