Gnostice PDFOne Java
Std. Ed. v2.10


com.gnostice.pdfone
Class PdfPrinter

java.lang.Object
  extended by com.gnostice.pdfone.PdfPrinter
All Implemented Interfaces:
Serializable

public class PdfPrinter
extends Object
implements Serializable

This class represents the printer component of PDFOne Java. To print a PDF document

  1. create a document object to read the document
  2. create a printer object and specify the document that needs to be printed
  3. call the print() method.
// Create a reader object with the document that  
// needs to be printed
PdfReader r = PdfReader.fileReader("sample_doc.pdf");

// Create a document object with the reader
PdfDocument d = new PdfDocument(r);

// Create a printer object
PdfPrinter printer = new PdfPrinter();

// Specify the document that needs to be printed
printer.setDocument(d);

// Print the document
printer.print("1", 2); // page range , number of copies 

// Close all I/O streams associated with 
// the reader object
r.dispose(); 

See Also:
Serialized Form

Constructor Summary
PdfPrinter()
          Zero-argument default constructor.
PdfPrinter(PdfDocument d)
          Constructs a PdfPrinter object with specified PdfDocument object.
 
Method Summary
 void print(String pageRange, int numOfCopies)
          Prints pages in specified page range for specified times.
 void print(String printerName, String pageRange, int numOfCopies)
          Prints pages in specified page range for specified times using specified printer.
 void setDocument(PdfDocument d)
          Specifies document that needs to be printed.
 void showPrintDialog()
          Displays a non-modal dialog box for receiving print settings from the user and then printing the document if required.
 void showPrintDialog(Dialog owner, boolean modal)
          Displays a modal or non-modal dialog box, with a specified dialog as the owner, for receiving print settings from the user and then printing the document if required.
 void showPrintDialog(Frame owner, boolean modal)
          Displays a modal or non-modal dialog box, with a specified frame as the owner, for receiving print settings from the user and then printing the document if required.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdfPrinter

public PdfPrinter()
Zero-argument default constructor.


PdfPrinter

public PdfPrinter(PdfDocument d)
Constructs a PdfPrinter object with specified PdfDocument object.

Parameters:
d - document that needs to be printed
Method Detail

setDocument

public void setDocument(PdfDocument d)
Specifies document that needs to be printed.

Parameters:
d - the document that needs to be printed

print

public void print(String pageRange,
                  int numOfCopies)
           throws IOException,
                  PdfException,
                  PrinterException
Prints pages in specified page range for specified times.

Parameters:
pageRange - pages that need to be printed
numOfCopies - number of times the pages need to be printed
Throws:
IOException - if an I/O error occurs.
PdfException - if an illegal argument is supplied.
PrinterException - if a printing error occurs.

print

public void print(String printerName,
                  String pageRange,
                  int numOfCopies)
           throws IOException,
                  PdfException,
                  PrinterException
Prints pages in specified page range for specified times using specified printer.

Parameters:
printerName - printer with which the pages need to be printed
pageRange - pages that need to be printed
numOfCopies - number of times the pages need to be printed
Throws:
IOException - if an I/O error occurs.
PdfException - if an illegal argument is supplied.
PrinterException - if a printing error occurs.

showPrintDialog

public void showPrintDialog()
                     throws PdfException
Displays a non-modal dialog box for receiving print settings from the user and then printing the document if required. On the dialog box, user can select the printer, page range, number of copies. The document is printed only if the OK button is selected. If the user selects the Cancel button, the document will not be printed.

Throws:
PdfException - if an illegal argument is supplied.

showPrintDialog

public void showPrintDialog(Frame owner,
                            boolean modal)
                     throws PdfException
Displays a modal or non-modal dialog box, with a specified frame as the owner, for receiving print settings from the user and then printing the document if required. On the dialog box, user can select the printer, page range, number of copies. The document is printed only if the OK button is selected. If the user selects the Cancel button, the document will not be printed.

Parameters:
owner - owner frame of the displayed dialog box
modal - whether the displayed dialog box needs to be a modal window
Throws:
PdfException - if an illegal argument is supplied.

showPrintDialog

public void showPrintDialog(Dialog owner,
                            boolean modal)
                     throws PdfException
Displays a modal or non-modal dialog box, with a specified dialog as the owner, for receiving print settings from the user and then printing the document if required. On the dialog box, user can select the printer, page range, number of copies. The document is printed only if the OK button is selected. If the user selects the Cancel button, the document will not be printed.

Parameters:
owner - owner dialog of the displayed dialog box
modal - whether the displayed dialog box needs to be a modal window
Throws:
PdfException - if an illegal argument is supplied.

Gnostice PDFOne Java
Std. Ed. v2.10

To contact our support team, send an e-mail to support@gnostice.com.
 
© 2008 Gnostice Information Technologies Private Limited. All rights reserved.
www.gnostice.com