Changes between Version 7 and Version 8 of BOOK_PRINTING_R1


Ignore:
Timestamp:
10/08/09 15:03:31 (16 years ago)
Author:
kyli
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BOOK_PRINTING_R1

    v7 v8  
    3030We will use the java.awt.print API. The simplest workflow for printing with this API consists of the following steps: 
    3131 
    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(). 
     321. Obtain a java.awt.print.PrinterJob instance. [[BR]] 
     332. 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]] 
     343. Call PrinterJob.printDialog() and if it returns true, call PrinterJob.print(). [[BR]] 
    3535 
    3636The 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".