JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.page.pcl
Class JCPCLPrinter

java.lang.Object
  |
  +--com.klg.jclass.page.JCPrinter
        |
        +--com.klg.jclass.page.pcl.JCPCLPrinter

public class JCPCLPrinter
extends JCPrinter

Implements the PrinterDriver interface.


Field Summary
protected static Rectangle2D.Double a3
          A european A3-size page (one of the HP-supported paper sizes).
protected static Rectangle2D.Double a4
          A european A4-size page (one of the HP-supported paper sizes).
protected  Rectangle2D currentPageSize
          Stores the size of the current page.
protected static Rectangle2D.Double executive
          An executive-size page (one of the HP-supported paper sizes).
protected  boolean isGL2Mode
          Whether or not the printer was last set to be in GL2 mode.
protected static Rectangle2D.Double ledger
          A "ledger"-size page (11x17) (one of the HP-supported paper sizes).
protected static Rectangle2D.Double legal
          A legal-size page.
protected static Rectangle2D.Double letter
          A letter-size page (one of the HP-supported paper sizes).
protected  Rectangle2D oldPageSize
          The last paper size that the output was set to accomodate.
 
Fields inherited from class com.klg.jclass.page.JCPrinter
bookmarkTree, bookmarkTreeVisible, collate, compressed, endPage, graphics, imageNumber, isDocOpen, numCopies, orientation, os, pageCount, printListeners, reverseOrder, startPage
 
Constructor Summary
JCPCLPrinter(OutputStream os)
          Creates a PCL printer given an OutputStream to write the data to.
JCPCLPrinter(OutputStream os, com.klg.jclass.page.FontParser parser, String jarLocation, String fileExtension, String fontMapFileName)
          Constructor.
 
Method Summary
 void beginPage(Rectangle2D pageSize, int pageNumber)
          Begins a new page in the document; establishes the co-ordinate system, sets margins and clipping, etc.
 void closeDocument(Rectangle2D pageSize)
          Completes the print job.
 void endPage(Rectangle2D pageSize)
          Completes the page and advances to the next one.
 Graphics getGraphics()
          Returns a graphics objects associated with this printer.
protected  int getPaperCode(double width, double height)
          Given width and height, returns the hp paper code.
 boolean isImageScalable()
          Returns true since PCL printer does own image scaling.
 void openDocument(Rectangle2D pageSize)
          Writes the PCL document header and setup information.
protected  boolean paperChanged(Rectangle2D pageSize)
          Determines if the paper size or orientation has changed.
 void setup()
          Creates default styles, any other one-time initialization (for example, builds font families from available fonts.).
protected  void setupPage(Rectangle2D pageSize)
          Outputs the commands to size and orients the page.
 
Methods inherited from class com.klg.jclass.page.JCPrinter
addPrintListener, getCollate, getFontFamilies, getNumCopies, getOrientation, getOutputPageEnd, getOutputPageStart, getOutputStream, getReverseOrder, isBookmarkTreeVisible, isCompressed, isDocumentOpen, isLandscape, output, output, output, output, removePrintListener, setCollate, setCompressed, setNumCopies, setOrientation, setOutputPageEnd, setOutputPageStart, setOutputStream, setReverseOrder, supportsHyperlinks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

oldPageSize

protected Rectangle2D oldPageSize
The last paper size that the output was set to accomodate.


isGL2Mode

protected boolean isGL2Mode
Whether or not the printer was last set to be in GL2 mode.


currentPageSize

protected Rectangle2D currentPageSize
Stores the size of the current page.


letter

protected static final Rectangle2D.Double letter
A letter-size page (one of the HP-supported paper sizes).


legal

protected static final Rectangle2D.Double legal
A legal-size page. (8.5x14) (one of the HP-supported paper sizes)


executive

protected static final Rectangle2D.Double executive
An executive-size page (one of the HP-supported paper sizes).


ledger

protected static final Rectangle2D.Double ledger
A "ledger"-size page (11x17) (one of the HP-supported paper sizes).


a4

protected static final Rectangle2D.Double a4
A european A4-size page (one of the HP-supported paper sizes).


a3

protected static final Rectangle2D.Double a3
A european A3-size page (one of the HP-supported paper sizes).

Constructor Detail

JCPCLPrinter

public JCPCLPrinter(OutputStream os,
                    com.klg.jclass.page.FontParser parser,
                    String jarLocation,
                    String fileExtension,
                    String fontMapFileName)
Constructor. Allows detailed specification of font creation. The constructor which takes one argument is akin to calling this constructor with these parameters:
		JCPrinter p = new JCPCLPrinter(
				someOutputStream,						// the output stream
				new com.klg.jclass.page.pcl.TFMParser(),	// the parser
				"/com/klg/jclass/page/pcl/fonts.jar", 	// jar location
				".tfm",									// file extension
				"com.klg.jclass.page.pcl.JCPCLFontMap");
 

Note: For large documents and for optimal performance, wrap the output stream in a BufferedOutputStream. For example:

 		BufferedOutputStream bos 	= new BufferedOutputStream(os, 2048);
 		JCPrinter printer 			= new JCPCLPrinter(bos, ...);
 

Parameters:
os - the OutputStream to which formatted output should be sent
parser - the FontParser which creates fonts from tfm files
jarLocation - the location of the jar containing tfm files relative to the class loader including the name of the jar file
fileExtension - the parser will turn files contained in "jarLocation" ending with this extension into fonts
fontMapFileName - the user fontmap file; a file containing mappings between font names and their aliases

JCPCLPrinter

public JCPCLPrinter(OutputStream os)
Creates a PCL printer given an OutputStream to write the data to.

Note: For large documents and for optimal performance, wrap the output stream in a BufferedOutputStream. For example:

 		BufferedOutputStream bos 	= new BufferedOutputStream(os, 2048);
 		JCPrinter printer 			= new JCPCLPrinter(bos);
 

Parameters:
os - the OutputStream to which to write the PCL data
Method Detail

setup

public void setup()
Creates default styles, any other one-time initialization (for example, builds font families from available fonts.).

Specified by:
setup in class JCPrinter

isImageScalable

public boolean isImageScalable()
Returns true since PCL printer does own image scaling.

Specified by:
isImageScalable in class JCPrinter
Returns:
true since PCL printer does own image scaling

openDocument

public void openDocument(Rectangle2D pageSize)
Writes the PCL document header and setup information.

Overrides:
openDocument in class JCPrinter
Parameters:
pageSize - the size of the first/default page

closeDocument

public void closeDocument(Rectangle2D pageSize)
Completes the print job.

Overrides:
closeDocument in class JCPrinter
Parameters:
pageSize - the size of the default/last page

beginPage

public void beginPage(Rectangle2D pageSize,
                      int pageNumber)
Begins a new page in the document; establishes the co-ordinate system, sets margins and clipping, etc.

Overrides:
beginPage in class JCPrinter
Parameters:
pageSize - the size of the new page
pageNumber - the number of the new page in the document

setupPage

protected void setupPage(Rectangle2D pageSize)
Outputs the commands to size and orients the page.

Parameters:
pageSize - the dimensions of the current page

getPaperCode

protected int getPaperCode(double width,
                           double height)
Given width and height, returns the hp paper code. Since width and height may be imprecise because of conversion between units -- be forgiving. If paper is wider than tall, we change width and height so we only deal in portrait.

Parameters:
width - the width of the page in points
height - the height of the page in points
Returns:
a code denoting the paper size

endPage

public void endPage(Rectangle2D pageSize)
Completes the page and advances to the next one.

Overrides:
endPage in class JCPrinter
Parameters:
pageSize - the size of the current page

getGraphics

public Graphics getGraphics()
Returns a graphics objects associated with this printer.

Overrides:
getGraphics in class JCPrinter
Returns:
a Graphics object to use to write to the PCL printer

paperChanged

protected boolean paperChanged(Rectangle2D pageSize)
Determines if the paper size or orientation has changed.

Parameters:
pageSize - the size of the next page to output
Returns:
true if the next page is different from the old page

Copyright © 2004 Quest Software Inc..
All rights reserved.