In practice, you usually shouldn’t pass a raw
Printable object to a print job. Instead, you should obtain an object of a class that implements the
Pageable interface. The Java platform supplies one such class, called
Book. A book is made up of sections, each of which is a
Printable object. To make a book, add
Printable objects and their page counts.
Book book = new Book(); Printable coverPage = . . .; Printable bodyPages = . . .; book.append(coverPage, pageFormat); // append 1 page book.append(bodyPages, pageFormat, pageCount);
Then, use the
setPageable method to pass the
Book object to the print job.
Now the print job knows exactly how many pages to print, ...