com.qoppa.pdfWriter
Class PDFPrinterJob

java.lang.Object
  extended byjava.awt.print.PrinterJob
      extended bycom.qoppa.pdfWriter.PDFPrinterJob
All Implemented Interfaces:
Runnable

public class PDFPrinterJob
extends PrinterJob
implements Runnable

Implementation of PrinterJob used to print to a PDF document. This class extends and emulates a standard Java PrinterJob object so that printing code can be reused to output to a PDF file.


Method Summary
 void cancel()
          Cancel printing the PDF document.
 PageFormat defaultPage()
          Returns the default page format for PDFPrinterJob.
 PageFormat defaultPage(PageFormat pf)
          Clones the PageFormat argument and alters the clone to describe a default page size and orientation.
 int getCopies()
          Returns the number of copies that will be printed.
 String getJobName()
          Returns the name of the printer job.
static PrinterJob getPrinterJob()
          Creates a new PDFPrinterJob.
 String getUserName()
          Returns the printer job's user name.
static String getVersion()
          Returns the version string for the jPDFWriter library.
 boolean isCancelled()
          Returns flag indicating whether this job has been cancelled.
 PageFormat pageDialog(PageFormat pf)
          Displays a dialog to request a page format from the user.
 void print()
          Initiates printing to the PDF document.
 void print(OutputStream outStream)
          Initiates printing to the PDF document, then writes the document to an OutputStream.
 void print(String outFileName)
          Initiates printing to the PDF document, then writes the document to a file.
 boolean printDialog()
          Shows the printer options dialog.
 PDFDocument printToDocument()
          Initiates printing to the PDF document, then returns the document to the calling program.
 void run()
          Internal method.
 void setCopies(int copies)
          Sets the number of copies to output.
 void setJobName(String jobName)
          Sets the printer job name.
static void setKey(String key)
          Sets product key.
 void setPageable(Pageable pageable)
          Sets the Pageable object to use when creating the PDF document.
 void setPrintable(Printable printable)
          Sets the Printable object to use when creating the PDF document.
 void setPrintable(Printable printable, PageFormat pf)
          Sets the Printable object and page format to user when creating the PDF document.
 PageFormat validatePage(PageFormat pf)
          Returns the clone of page with its settings adjusted to be compatible with the current printer of this PrinterJob.
 
Methods inherited from class java.awt.print.PrinterJob
getPrintService, lookupPrintServices, lookupStreamPrintServices, pageDialog, print, printDialog, setPrintService
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

cancel

public void cancel()
Cancel printing the PDF document.


defaultPage

public PageFormat defaultPage()
Returns the default page format for PDFPrinterJob.

Returns:
Default page format.

defaultPage

public PageFormat defaultPage(PageFormat pf)
Clones the PageFormat argument and alters the clone to describe a default page size and orientation.

Parameters:
pf - the PageFormat to be cloned and altered
Returns:
clone of page, altered to describe a default PageFormat.

getCopies

public int getCopies()
Returns the number of copies that will be printed.

Returns:
Number of copies.

getJobName

public String getJobName()
Returns the name of the printer job.

Returns:
Name of the printer job.

getPrinterJob

public static PrinterJob getPrinterJob()
Creates a new PDFPrinterJob.

Returns:
New PDFPrinterJob.

getUserName

public String getUserName()
Returns the printer job's user name.

Returns:
The printer job's user name.

getVersion

public static String getVersion()
Returns the version string for the jPDFWriter library.

Returns:
String jPDFWriter library version.

isCancelled

public boolean isCancelled()
Returns flag indicating whether this job has been cancelled.

Returns:
boolean

pageDialog

public PageFormat pageDialog(PageFormat pf)
Displays a dialog to request a page format from the user. Initializes the dialog to a given PageFormat.

Parameters:
pf - java.awt.print.PageFormat
Returns:
java.awt.print.PageFormat

print

public void print()
           throws PrinterException
Initiates printing to the PDF document.

Throws:
PrinterException

print

public void print(OutputStream outStream)
           throws PrinterException
Initiates printing to the PDF document, then writes the document to an OutputStream.

Parameters:
outStream - OutputStream to write the PDF document to.
Throws:
PrinterException

print

public void print(String outFileName)
           throws PrinterException
Initiates printing to the PDF document, then writes the document to a file.

Parameters:
outFileName - File to write the PDF document to. Creation date: (4/29/2002 11:00:27 PM)
Throws:
PrinterException

printToDocument

public PDFDocument printToDocument()
                            throws PrinterException
Initiates printing to the PDF document, then returns the document to the calling program. This method simply creates a PDFDocument object and makes all the necessary calls to the registered Printable or Pageable object, it does NOT save the PDF document to a file. Saving of the document is left up to the calling application.

Returns:
A reference to the PDFDocument object that was created through the PrinterJob. The calling application can then call the PDFDocument.saveDocument method to save the document.
Throws:
PrinterException

printDialog

public boolean printDialog()
Shows the printer options dialog. jPDFWriter shows a file chooser dialog when this method is called to prompt the user for an output file.

Returns:
boolean

run

public void run()
Internal method.

Specified by:
run in interface Runnable

setCopies

public void setCopies(int copies)
Sets the number of copies to output. Copies will be written sequentially to the same PDF file.

Parameters:
copies - int

setJobName

public void setJobName(String jobName)
Sets the printer job name.

Parameters:
jobName - java.lang.String

setPageable

public void setPageable(Pageable pageable)
Sets the Pageable object to use when creating the PDF document.

Parameters:
pageable - java.awt.print.Pageable

setPrintable

public void setPrintable(Printable printable)
Sets the Printable object to use when creating the PDF document.

Parameters:
printable - java.awt.print.Printable

setPrintable

public void setPrintable(Printable printable,
                         PageFormat pf)
Sets the Printable object and page format to user when creating the PDF document.

Parameters:
printable - java.awt.print.Printable

validatePage

public PageFormat validatePage(PageFormat pf)
Returns the clone of page with its settings adjusted to be compatible with the current printer of this PrinterJob.

Parameters:
pf - java.awt.print.PageFormat
Returns:
java.awt.print.PageFormat

setKey

public static void setKey(String key)
Sets product key. Use this method after purchasing to remove evaluation restrictions.

Parameters:
key - - Product key.