Changes between Version 7 and Version 8 of BOOK_PRINTING_R1
- Timestamp:
- 10/08/09 15:03:31 (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
BOOK_PRINTING_R1
v7 v8 30 30 We will use the java.awt.print API. The simplest workflow for printing with this API consists of the following steps: 31 31 32 1. Obtain a java.awt.print.PrinterJob instance. 33 2. Pass a java.awt.print.Printable or java.awt.print.Pageable object to the PrinterJob instance (we will use Pageable since it fits our needs better). 34 3. Call PrinterJob.printDialog() and if it returns true, call PrinterJob.print(). 32 1. Obtain a java.awt.print.PrinterJob instance. [[BR]] 33 2. Pass a java.awt.print.Printable or java.awt.print.Pageable object to the PrinterJob instance (we will use Pageable since it fits our needs better). [[BR]] 34 3. Call PrinterJob.printDialog() and if it returns true, call PrinterJob.print(). [[BR]] 35 35 36 36 The only thing we need to do to make this work in Sophie2 is to create a custom Pageable object at step 2. We will create a java.awt.print.Book (which implements Pageable) by passing it a PagePainter (implements Printable) object which can print each page of a Sophie2 book. PagePainter's constructor will have one parameter of type BookView. The PagePainter.print method will draw a page from the BookView (by given page index) to a given Graphics2D object. The drawing will be done in the exact same way as "export to pdf".