Class PrinterJobProgress

  • All Implemented Interfaces:
    java.awt.print.Printable, java.lang.Runnable

    public class PrinterJobProgress
    extends Progress
    implements java.awt.print.Printable
    This is a background progress for printing. If you want use this class directly for background printing then you can use a code like:
    
      PrinterJob printerJob = PrinterJob.getPrinterJob();
      PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();
      Progress progress = new PrinterJobProgress(null, printerJob, attributeSet, data);
      progress.startProgress();
      ....
      progress.waitUntilFinished();
     
    • Constructor Detail

      • PrinterJobProgress

        public PrinterJobProgress​(ReportView parent,
                                  java.awt.print.PrinterJob printerJob,
                                  javax.print.attribute.PrintRequestAttributeSet attributeSet,
                                  RenderData data)
        Creates a new Thread for printing in the background.
        Parameters:
        parent - if this null then Error messages will not display.
        printerJob - The PrinterJob with the target PrintService.
        attributeSet - A list of attributes that override values in the report design. For example paper format, paper orientation and page margins.
        data - The data of the report that should be printed.
        Since:
        7.0
    • Method Detail

      • getName

        public final java.lang.String getName()
        The name of the daemon thread.
        Specified by:
        getName in class Progress
        Returns:
        the name of the daemon thread.
        Since:
        7.0
      • cancel

        public void cancel()
        Call this method to force a cancel of the progress - which must also set both of the states "finished" and "canceled" to true. Please note: some progresses may not be stoppable.
        Specified by:
        cancel in class Progress
        Since:
        7.0
      • initPrintRequestAttributes

        public void initPrintRequestAttributes()
        Initialize missing print attributes from the render data. Is call from the progress.
        Since:
        17.0
      • run

        public void run()
        This is the run method of the thread.
        Specified by:
        run in interface java.lang.Runnable
        Since:
        7.0
      • print

        public int print​(java.awt.Graphics g,
                         java.awt.print.PageFormat currentPageFormat,
                         int pageIndex)
                  throws java.awt.print.PrinterException
        FOR INTERNAL USE ONLY
        Specified by:
        print in interface java.awt.print.Printable
        Parameters:
        g - the context into which the page is drawn
        currentPageFormat - the size and orientation of the page being drawn
        pageIndex - the zero based index of the page to be drawn
        Returns:
        PAGE_EXISTS or NO_SUCH_PAGE
        Throws:
        java.awt.print.PrinterException - If it has occurred during printing
        Since:
        7.0