Package pdf

Class PDFPrinterJob


  • public class PDFPrinterJob
    extends java.awt.print.PrinterJob

    This class extends awt's PrinterJob, to provide a simple method of writing PDF documents.

    You can use this with any code that uses Java's printing mechanism. It does include a few extra methods to provide access to some of PDF's features like annotations, or outlines.

    • Constructor Summary

      Constructors 
      Constructor Description
      PDFPrinterJob()
      Initializes a new instance of PDFPrinterJob.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cancel()  
      java.awt.print.PageFormat defaultPage​(java.awt.print.PageFormat page)  
      int getCopies()  
      java.lang.String getJobName()  
      static java.awt.print.PrinterJob getPrinterJob()  
      java.lang.String getUserName()  
      boolean isCancelled()  
      java.awt.print.PageFormat pageDialog​(java.awt.print.PageFormat page)  
      void print()  
      void print​(java.lang.String pathname)
      Prints a set of pages.
      boolean printDialog()  
      void setAuthor​(java.lang.String author)
      Sets the author for this document.
      void setCopies​(int copies)  
      void setCreator​(java.lang.String creator)
      Sets the creator for this document.
      void setJobName​(java.lang.String jobName)  
      void setPageable​(java.awt.print.Pageable document)  
      void setPrintable​(java.awt.print.Printable painter)  
      void setPrintable​(java.awt.print.Printable painter, java.awt.print.PageFormat format)  
      void setTitle​(java.lang.String title)
      Sets the title for this document.
      java.awt.print.PageFormat validatePage​(java.awt.print.PageFormat page)  
      • Methods inherited from class java.awt.print.PrinterJob

        defaultPage, getPageFormat, getPrintService, lookupPrintServices, lookupStreamPrintServices, pageDialog, print, printDialog, setPrintService
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PDFPrinterJob

        public PDFPrinterJob()
        Initializes a new instance of PDFPrinterJob.
    • Method Detail

      • cancel

        public void cancel()
        Specified by:
        cancel in class java.awt.print.PrinterJob
      • defaultPage

        public java.awt.print.PageFormat defaultPage​(java.awt.print.PageFormat page)
        Specified by:
        defaultPage in class java.awt.print.PrinterJob
      • getCopies

        public int getCopies()
        Specified by:
        getCopies in class java.awt.print.PrinterJob
      • getJobName

        public java.lang.String getJobName()
        Specified by:
        getJobName in class java.awt.print.PrinterJob
      • getPrinterJob

        public static java.awt.print.PrinterJob getPrinterJob()
      • getUserName

        public java.lang.String getUserName()
        Specified by:
        getUserName in class java.awt.print.PrinterJob
      • isCancelled

        public boolean isCancelled()
        Specified by:
        isCancelled in class java.awt.print.PrinterJob
      • pageDialog

        public java.awt.print.PageFormat pageDialog​(java.awt.print.PageFormat page)
                                             throws java.awt.HeadlessException
        Specified by:
        pageDialog in class java.awt.print.PrinterJob
        Throws:
        java.awt.HeadlessException
      • print

        public void print​(java.lang.String pathname)
                   throws java.awt.print.PrinterException
        Prints a set of pages.
        Parameters:
        pathname - the full path for the output PDF file.
        Throws:
        java.awt.print.PrinterException - an error in the print system caused the job to be aborted.
        See Also:
        Book, Pageable, Printable
      • print

        public void print()
                   throws java.awt.print.PrinterException
        Specified by:
        print in class java.awt.print.PrinterJob
        Throws:
        java.awt.print.PrinterException
      • printDialog

        public boolean printDialog()
                            throws java.awt.HeadlessException
        Specified by:
        printDialog in class java.awt.print.PrinterJob
        Throws:
        java.awt.HeadlessException
      • setAuthor

        public void setAuthor​(java.lang.String author)
        Sets the author for this document.
        Parameters:
        author - the author's name.
      • setCopies

        public void setCopies​(int copies)
        Specified by:
        setCopies in class java.awt.print.PrinterJob
      • setCreator

        public void setCreator​(java.lang.String creator)
        Sets the creator for this document.
        Parameters:
        creator - the application name.
      • setJobName

        public void setJobName​(java.lang.String jobName)
        Specified by:
        setJobName in class java.awt.print.PrinterJob
      • setPageable

        public void setPageable​(java.awt.print.Pageable document)
                         throws java.lang.NullPointerException
        Specified by:
        setPageable in class java.awt.print.PrinterJob
        Throws:
        java.lang.NullPointerException
      • setPrintable

        public void setPrintable​(java.awt.print.Printable painter)
        Specified by:
        setPrintable in class java.awt.print.PrinterJob
      • setPrintable

        public void setPrintable​(java.awt.print.Printable painter,
                                 java.awt.print.PageFormat format)
        Specified by:
        setPrintable in class java.awt.print.PrinterJob
      • setTitle

        public void setTitle​(java.lang.String title)
        Sets the title for this document.
        Parameters:
        title - the document title.
      • validatePage

        public java.awt.print.PageFormat validatePage​(java.awt.print.PageFormat page)
        Specified by:
        validatePage in class java.awt.print.PrinterJob