com.openpcl.viewer.printing
Class PCLPrintJob
java.lang.Object
com.openpcl.viewer.printing.PCLPrintJob
- All Implemented Interfaces:
- ImageObserver, Pageable, Printable
public class PCLPrintJob
- extends Object
- implements Pageable, Printable, ImageObserver
The purpose of this class is to handle the printing of a PCL bytestream to the printer, whether it uses
PCLDirect or GDI. PCLDirect is the fastest but requires the printer selected to handle PCL 5 or higher.
GDI is compatible with all printers but is slower since each page must be rendered before being sent to the printer.
- Author:
- DocMagic, Document Systems Inc, Jim Gabriel. Sept 18, 2007
9/18/07 to 9/25/07 Howard Hoagland. Changed significantly to make it work with OpenPCLViewer and PosPrintPages
so that printing PCL Direct and Windows Print uses this class only and doesn't use PosPrintBufferedImage
and PosPrintPageableInterface, because this class implements the methods of both those Interfaces and in fact
the code from those two classes was cut and pasted into this class to make it do the job of those two. The main benefit
of this class is to implement printing duplex for Windows Print.
Helpful reference URLs used to create and design this class
http://www.javaworld.com/javaworld/jw-10-2000/jw-1020-print.html
http://java.sun.com/products/java-media/2D/forDevelopers/sdk12print.html
http://www.java2s.com/Code/Java/2D-Graphics-GUI/PageableText.htm
Method Summary |
int |
getNumberOfPages()
|
PageFormat |
getPageFormat(int pPageNumber)
|
Printable |
getPrintable(int pForPageNumber)
|
PrintRequestAttributeSet |
getPrintRequestAttributeSet()
|
boolean |
imageUpdate(Image img,
int infoflags,
int x,
int y,
int w,
int h)
|
void |
initializePrintJob(com.openpcl.viewer.printing.PCLPrintJob.PrintModeEnum pPrintModeEnum,
com.openpcl.viewer.printing.PCLPrintJob.OutputPageSizeEnum pOutputPageSizeEnum,
String pPrintJobName,
byte[] pPCLData,
PrinterJob pPrinterJob)
Pass in parameters needed to initialize the printing for the next printout. |
static void |
main(String[] args)
The main() here is for unit testing and to show how to use this class from the app using this class. |
int |
print(Graphics pGraphics,
PageFormat pPageFormat,
int pPageNumber)
This is the main CALLBACK method for the java.awt.print.Prinable interface
Note that the page number passed in is 0 based. |
void |
setPrintingProgressBar(JProgressBar pPrintingProgressBar)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
mByteArrayOutputStream
protected ByteArrayOutputStream mByteArrayOutputStream
mPrintService
protected PrintService mPrintService
mPrintDocGDI
protected PclRenderImage mPrintDocGDI
mPagesPrinted
protected int mPagesPrinted
mCurrentPageSize
protected String mCurrentPageSize
mPrintAllOnLegal
protected boolean mPrintAllOnLegal
mPrintJobName
protected String mPrintJobName
mAttr
protected PrintRequestAttributeSet mAttr
mLastFormName
protected String mLastFormName
mLastPageNumber
protected int mLastPageNumber
mIsDuplex
protected boolean mIsDuplex
mPrintModeEnum
public com.openpcl.viewer.printing.PCLPrintJob.PrintModeEnum mPrintModeEnum
mOutputPageSizeEnum
public com.openpcl.viewer.printing.PCLPrintJob.OutputPageSizeEnum mOutputPageSizeEnum
PCLPrintJob
public PCLPrintJob()
- Constructor
getPrintRequestAttributeSet
public PrintRequestAttributeSet getPrintRequestAttributeSet()
initializePrintJob
public void initializePrintJob(com.openpcl.viewer.printing.PCLPrintJob.PrintModeEnum pPrintModeEnum,
com.openpcl.viewer.printing.PCLPrintJob.OutputPageSizeEnum pOutputPageSizeEnum,
String pPrintJobName,
byte[] pPCLData,
PrinterJob pPrinterJob)
- Pass in parameters needed to initialize the printing for the next printout.
- Parameters:
pPrintMode
- pOutputPageSize
- pPrintJobName
- pPCLData
- pPrinterJob
- pIsDuplex
-
print
public int print(Graphics pGraphics,
PageFormat pPageFormat,
int pPageNumber)
throws PrinterException
- This is the main CALLBACK method for the java.awt.print.Prinable interface
Note that the page number passed in is 0 based.
- Specified by:
print
in interface Printable
- Throws:
PrinterException
imageUpdate
public boolean imageUpdate(Image img,
int infoflags,
int x,
int y,
int w,
int h)
- Specified by:
imageUpdate
in interface ImageObserver
getNumberOfPages
public int getNumberOfPages()
- Specified by:
getNumberOfPages
in interface Pageable
getPrintable
public Printable getPrintable(int pForPageNumber)
throws IndexOutOfBoundsException
- Specified by:
getPrintable
in interface Pageable
- Throws:
IndexOutOfBoundsException
getPageFormat
public PageFormat getPageFormat(int pPageNumber)
throws IndexOutOfBoundsException
- Specified by:
getPageFormat
in interface Pageable
- Throws:
IndexOutOfBoundsException
setPrintingProgressBar
public void setPrintingProgressBar(JProgressBar pPrintingProgressBar)
main
public static void main(String[] args)
- The main() here is for unit testing and to show how to use this class from the app using this class.
- Parameters:
args
-
OpenPCL http://www.openpcl.com