Java Reference
In-Depth Information
How It Works
The PrinterJob object now calls methods in the Pageable interface that you have implemented in the
SketcherView class that defines the view object. The number of pages in the document is now determin-
ed by the getNumberOfPages() method, and the PageFormat and Printable objects are now obtained
individually for each page.
If you switch the code back to using the printDialog() and print() methods with an argument
of type PrintRequestAttributeSet , the print operation runs in the same way. The print attributes
passed to the print() method do not override those specified in the PageFormat object returned by the
getPageFormat() method for the Pageable object. If the attribute set passed to the print method in-
cludes attributes not determined by the Pageable object — such as a Copies attribute object — these
have an effect on the printing process. Similarly, if you set the page orientation to landscape using the
dialog displayed by the Print Setup menu item, the second page that contains the sketch prints in land-
scape orientation.
Printing Using a Book
A Book object is a repository for a collection of pages where the pages may be printed using different
formats. The page painter for a page in a book is represented by a Printable object, and each Printable
object within a book can print one or possibly several pages with a given format. Figure 21-16 shows an
example of a Book object that uses three Printable objects to print a total of seven pages.
FIGURE 21-16
 
 
Search WWH ::




Custom Search