JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.page.adobe.pdf
Class JCPDFPrinter

java.lang.Object
  |
  +--com.klg.jclass.page.JCPrinter
        |
        +--com.klg.jclass.page.adobe.pdf.JCPDFPrinter

public class JCPDFPrinter
extends JCPrinter

Interface methods for document handling


Nested Class Summary
protected  class JCPDFPrinter.AcroReference
          Class AcroReference defines a PDF cross-reference marker
protected  class JCPDFPrinter.PatternInfo
          Contains pattern-related information.
 class JCPDFPrinter.StreamInfo
          Information related to PDF 'stream' object which can be used for current page body but also for form and image XObjects.
 
Field Summary
protected  TreeMap annoInternalLocations
          Internal use only - do not use
protected  Hashtable annoInternalPages
          Internal use only - do not use
protected  Vector annotationList
          A List of annotations on the current Page
protected  Vector annotationRectangles
          Internal use only - do not use
protected  Rectangle2D bounds
          The bounding box of the current page
protected  Vector contentsList
          A List of contents streams on the current Page
protected  int currentPageObjectNumber
          The object reference number of the current Page object
protected  Rectangle2D currentPageSize
          Track the size of the current page being printed
protected  Vector docImageList
          List of document Image objects
protected  boolean docOpen
          Records if the document has been opened.
protected  boolean drawingJavaComponent
          True if drawing java component.
protected  int drawJavaComponentLengthObjectNumber
          Object number for java component's length object.
protected  int drawJavaComponentObjectNumber
          Object number for java component.
protected  int drawJavaComponentResourcesObjectNumber
          Object number for java component's resource dictionary.
protected  int encodingObj
          The object reference number of the standard Font encoding
protected  Hashtable fontList
          A Set of Fonts which have been used in the document
protected  int graphicsDictionaryObj
          The object reference number of the document Graphics State Dictionary
protected  Vector hyperlinkInfoList
          Internal use only - do not use
protected  Hashtable hyperlinkObjects
          Internal use - do not use
protected  WeakHashMap imageCache
          List of available images
protected  int objectNumber
          The number to be allocated to the next object created
protected  Rectangle2D oldPageSize
          Track the size and orientation of the last page printed
protected  Vector pageList
          A List of the Page objects in the current Pages object
protected  Vector pagesList
          A List of the Pages objects in the document
protected  int pagesReference
          The object reference number of the current Pages object
protected  Vector pageXObjectReferences
          List of XObject Reference Lists for current page.
protected  Vector pageXObjectStreams
          List of XObject Reference Streams for current page.
protected  int rootPagesReference
          The object reference number of the root Pages object
protected  JCPDFPrinter.StreamInfo streamInfo
          Information for current page or xobject stream.
protected  Stack streamStack
          Stack of StreamInfo objects.
protected  int totalPageCount
          The total number of pages output in this PDF document
protected  boolean useAutoStrokeAdjustment
          Determines whether to use PDF Line Stroke Adjustment mode or not.
 
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
JCPDFPrinter(OutputStream os)
          Construct a PDF printer given an OutputStream.
JCPDFPrinter(OutputStream os, com.klg.jclass.page.FontParser parser, String jarLocation, String fileExtension, String fontMapFileName)
          Allows detailed specification of font creation.
 
Method Summary
protected  void addFontToList(com.klg.jclass.page.adobe.postscript.FontPS font)
          Adds a font to the document's list of fonts.
protected  void addPattern(String patternName, BufferedImage img)
           
protected  void beginNonPageStream()
          Begin a non-page stream.
 void beginPage(Rectangle2D pageSize, int pageNumber)
          Starts a page; create the correct initial transformation and initialise the page resources lists.
protected  void beginPageStream()
          Begin a page stream.
 void closeDocument(Rectangle2D pageSize)
          Completes the document (pages tree, cross-references, trailer).
protected  void createNecessaryFontObjects(Hashtable thisFontList)
          Given a List of font names, created the necessary font entry objects and store them in the master font list.
 void endPage(Rectangle2D pageSize)
          Complete the page (terminate the contents stream, write out the Page object including all resources used on the page.
protected  void endStream()
          End stream.
 String formatHexString(int value, int numChars)
          Format an integer as a hex string, padding the beginning of the string with zeroes until it is the requested number of characters.
 boolean getAutoStrokeAdjustment()
          Get the value of the AutoStrokeAdjustment property.
protected  long getCurrentOffset()
          Gets the current offset into the output stream.
protected  String getFontAbbreviation(String fontName)
          Gets the abbreviation for a given font name.
protected  com.klg.jclass.page.adobe.pdf.AcroFontEntry getFontEntry(String fontName)
          Gets the AcroFontEntry class associated with the requested font
 Graphics getGraphics()
          Gets the graphics context used by this printer.
protected  long getStreamStart()
          Gets the start (initial offset) of the current contents stream.
 boolean isBaseFont(String name)
          Determines if a given font name represents one of the 3 standard (built-in) PDF font families.
 boolean isCompressed()
          Returns true if this printer will generate compressed output
 boolean isDocOpen()
          Returns whether or not openDocument has already been called.
 boolean isImageScalable()
          Returns true since PDF can scale images itself.
 void openDocument(Rectangle2D pageSize)
          Initialise the document (document header, initialise lists).
protected  void output(byte oneByte)
          Write the specified byte to the output, tracking the number of bytes written.
protected  void output(byte[] bytes)
          Write the given byte array to the output, tracking the number of bytes written.
protected  void output(byte[] bytes, int off, int len)
          Write the specified subsection of the given byte array to the output, tracking the number of bytes written.
protected  void output(String string)
          Write the given string to the output, tracking the number of bytes written and adding a new-line at the end of the string.
protected  void outputBookmarkTree(DefaultMutableTreeNode rootNode, int rootObjectNumber)
          /** Internal use method (noop).
protected  String pad10(long offset)
          Zero-pad the given number (file offset) as a 10-digit decimal number
protected  boolean pageChanged(Rectangle2D pageSize)
          Determines if the page has changed, which would require a new Pages object to be started.
 void setAutoStrokeAdjustment(boolean useASA)
          Set the value of the AutoStrokeAdjustment property.
 void setCompressed(boolean compress)
          Sets whether or not this printer will generate compressed output.
 void setOutputStream(OutputStream os)
          Sets output stream for PostScript, PDF and PCL printers.
protected  void setStreamStart()
          Marks the start of a contents stream (at the current offset).
 void setup()
          Creates default styles, any other one-time initialisation Builds font families from available fonts.
protected  void storeObjectReference(int objNumber, long offset)
          Stores the cross-reference table information about an object (number, offset).
 boolean supportsHyperlinks()
          Returns true if this printer supports hyperlinks.
protected  void switchBackToOldStream()
          Switch back to the previously used stream.
protected  void switchToNewStream()
          Switch output to a buffered stream which will be collected and written out following the end of the current page stream.
protected  void writeCharRangeDiffWidth(com.klg.jclass.page.adobe.postscript.FontPS font, int start, int end)
          Write out character widths for a CID font descriptor in the format "startchar [width-1 width-2 ...
protected  void writeCharRangeSameWidth(com.klg.jclass.page.adobe.postscript.FontPS font, int start, int end)
          Write out character widths for a CID font descriptor in the format "startchar endchar width".
protected  int writeCompressedStreamBody(byte[] byteArray)
          Write the body (i.e.
protected  void writeCompressedStreamFooter(int streamLengthObjectNumber, int streamLength)
          Write the tail end of a compressed stream object to the output, including the endstream/endjob commands and an object containing the stream length.
protected  void writeCompressedStreamHeader(int streamObjectNumber, int streamLengthObjectNumber, String extraEntries)
          Write the beginning of a compressed stream object to the output, including the filter specifications and the stream command.
protected  void writeCompressedStreamObject(int streamObjectNumber, byte[] byteArray, String extraEntries)
          Write a compressed stream object to the output.
protected  void writeCompressedStreamObject(int streamObjectNumber, ByteArrayOutputStream byteArrayOS, String extraEntries)
          Write a compressed stream object to the output.
protected  void writeDocGraphicsDictionary()
          Writes the encoding vector of the standard (ISO Latin1) character set.
protected  void writeFontDescription(com.klg.jclass.page.adobe.pdf.AcroFontEntry fontEntry)
          Writes the font description to the output.
protected  void writeFontDescriptor(int fontDescriptorObjectNumber, com.klg.jclass.page.adobe.pdf.AcroFontEntry fontEntry, com.klg.jclass.page.adobe.postscript.FontPS font, String fontNameInDescriptor)
          Write the actual PDF Font Descriptor to the output.
protected  void writeFontEncoding()
          Writes the encoding vector of the standard (ISO Latin1) character set.
protected  void writePagesObject(int referenceNumber, Vector childList, int parent, Rectangle2D pageSize)
          Writes out a Pages object.
protected  void writePagesTree(Rectangle2D pageSize)
          Completes and write the pages tree.
protected  void writePatternDescription(JCPDFPrinter.PatternInfo patternInfo)
           
protected  void writeResourcesDictionary()
          Write a Resources Dictionary based on the current StreamInfo.
protected  void writeResourcesFontList(Hashtable thisFontList)
          Write the Font list entry of a Resources dictionary.
protected  void writeResourcesPatternList()
           
protected  void writeToUnicodeCMap(int toUnicodeObjectNumber, com.klg.jclass.page.adobe.pdf.AcroFontEntry fontEntry, com.klg.jclass.page.adobe.postscript.FontPS font)
          Write a ToUnicode CMap as a stream object.
protected  void writeUncompressedStreamFooter(int streamLengthObjectNumber, int streamLength)
          Write the tail end of an uncompressed stream object to the output, including the endstream/endjob commands and an object containing the stream length.
protected  void writeUncompressedStreamHeader(int streamObjectNumber, int streamLengthObjectNumber, String extraEntries)
          Write the beginning of an uncompressed stream object to the output, including the stream command.
protected  void writeUncompressedStreamObject(int streamObjectNumber, String contents, String extraEntries)
          Write uncompressed (text) stream object to the output.
 
Methods inherited from class com.klg.jclass.page.JCPrinter
addPrintListener, getCollate, getFontFamilies, getNumCopies, getOrientation, getOutputPageEnd, getOutputPageStart, getOutputStream, getReverseOrder, isBookmarkTreeVisible, isDocumentOpen, isLandscape, removePrintListener, setCollate, setNumCopies, setOrientation, setOutputPageEnd, setOutputPageStart, setReverseOrder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objectNumber

protected int objectNumber
The number to be allocated to the next object created


rootPagesReference

protected int rootPagesReference
The object reference number of the root Pages object


totalPageCount

protected int totalPageCount
The total number of pages output in this PDF document


pagesReference

protected int pagesReference
The object reference number of the current Pages object


currentPageObjectNumber

protected int currentPageObjectNumber
The object reference number of the current Page object


encodingObj

protected int encodingObj
The object reference number of the standard Font encoding


graphicsDictionaryObj

protected int graphicsDictionaryObj
The object reference number of the document Graphics State Dictionary


pageList

protected Vector pageList
A List of the Page objects in the current Pages object


pagesList

protected Vector pagesList
A List of the Pages objects in the document


contentsList

protected Vector contentsList
A List of contents streams on the current Page


annotationList

protected Vector annotationList
A List of annotations on the current Page


fontList

protected Hashtable fontList
A Set of Fonts which have been used in the document


bounds

protected Rectangle2D bounds
The bounding box of the current page


oldPageSize

protected Rectangle2D oldPageSize
Track the size and orientation of the last page printed


currentPageSize

protected Rectangle2D currentPageSize
Track the size of the current page being printed


docOpen

protected boolean docOpen
Records if the document has been opened.


imageCache

protected WeakHashMap imageCache
List of available images


docImageList

protected Vector docImageList
List of document Image objects


useAutoStrokeAdjustment

protected boolean useAutoStrokeAdjustment
Determines whether to use PDF Line Stroke Adjustment mode or not.


drawJavaComponentObjectNumber

protected int drawJavaComponentObjectNumber
Object number for java component.


drawJavaComponentLengthObjectNumber

protected int drawJavaComponentLengthObjectNumber
Object number for java component's length object.


drawJavaComponentResourcesObjectNumber

protected int drawJavaComponentResourcesObjectNumber
Object number for java component's resource dictionary.


drawingJavaComponent

protected boolean drawingJavaComponent
True if drawing java component.


annotationRectangles

protected Vector annotationRectangles
Internal use only - do not use


hyperlinkInfoList

protected Vector hyperlinkInfoList
Internal use only - do not use


hyperlinkObjects

protected Hashtable hyperlinkObjects
Internal use - do not use


annoInternalLocations

protected TreeMap annoInternalLocations
Internal use only - do not use


annoInternalPages

protected Hashtable annoInternalPages
Internal use only - do not use


streamInfo

protected JCPDFPrinter.StreamInfo streamInfo
Information for current page or xobject stream.


streamStack

protected Stack streamStack
Stack of StreamInfo objects. Used to save page stream while writing XObject stream.


pageXObjectReferences

protected Vector pageXObjectReferences
List of XObject Reference Lists for current page.


pageXObjectStreams

protected Vector pageXObjectStreams
List of XObject Reference Streams for current page.

Constructor Detail

JCPDFPrinter

public JCPDFPrinter(OutputStream os)
Construct a PDF printer given an OutputStream. Akin to calling the 5-parameter constructor with these values:
      JCPrinter p = new JCPDFPrinter(
              someOutputStream,                       // the output stream
              new com.klg.jclass.page.adobe.postscript.AFMParser(), // the parser
              "/com/klg/jclass/page/adobe/fonts.jar", // jar location
              ".afm",                                 // file extension
              "com.klg.jclass.page.adobe.JCAdobeFontMap");
 

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

      BufferedOutputStream bos    = new BufferedOutputStream(os, 2048);
      JCPrinter printer           = new JCPDFPrinter(bos, ...);
 
would create a buffer large enough to hold a document of 2Kb.

Parameters:
os - The OutputStream to which the PDF is written
See Also:
AFMParser

JCPDFPrinter

public JCPDFPrinter(OutputStream os,
                    com.klg.jclass.page.FontParser parser,
                    String jarLocation,
                    String fileExtension,
                    String fontMapFileName)
Allows detailed specification of font creation. Only .afm files may be added using this constructor.

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

      BufferedOutputStream bos    = new BufferedOutputStream(os, 2048);
      JCPrinter printer           = new JCPDFPrinter(bos, ...);
 
would create a buffer large enough to hold a document of 2Kb.

Parameters:
os - the OutputStream to which formatted output should be sent
parser - the FontParser which creates fonts from afm files. Currently, only instances of com.klg.jclass.adobe.postscript.AFMParser are supported.
jarLocation - the location of the jar containing afm 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
See Also:
AFMParser.AFMParser(java.lang.String)
Method Detail

setOutputStream

public void setOutputStream(OutputStream os)
Description copied from class: JCPrinter
Sets output stream for PostScript, PDF and PCL printers.

Overrides:
setOutputStream in class JCPrinter
Parameters:
os - the stream to which output will be written

setAutoStrokeAdjustment

public void setAutoStrokeAdjustment(boolean useASA)
Set the value of the AutoStrokeAdjustment property. This property determines whether output PDF uses Line Stroke Adjustment mode or not. (The default is true.) Using Line Stroke Adjustment will ensure that lines defined to be the same size get drawn as the same number of pixels when renderered to the screen, but the resulting changes in the position of lines may mean that some lines (such as those used by table borders) no longer connect exactly. See PDF reference documentation (available from Adobe) for more information.


getAutoStrokeAdjustment

public boolean getAutoStrokeAdjustment()
Get the value of the AutoStrokeAdjustment property. This property determines whether output PDF uses Line Stroke Adjustment mode or not. (The default is true.) Using Line Stroke Adjustment will ensure that lines defined to be the same size get drawn as the same number of pixels when renderered to the screen, but the resulting changes in the position of lines may mean that some lines (such as those used by table borders) no longer connect exactly. See PDF reference documentation (available from Adobe) for more information.


isDocOpen

public boolean isDocOpen()
Returns whether or not openDocument has already been called.

Returns:
docOpen

setup

public void setup()
Creates default styles, any other one-time initialisation Builds font families from available fonts.

Specified by:
setup in class JCPrinter

isImageScalable

public boolean isImageScalable()
Returns true since PDF can scale images itself.

Specified by:
isImageScalable in class JCPrinter

openDocument

public void openDocument(Rectangle2D pageSize)
Initialise the document (document header, initialise lists).

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

closeDocument

public void closeDocument(Rectangle2D pageSize)
Completes the document (pages tree, cross-references, trailer).

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

outputBookmarkTree

protected void outputBookmarkTree(DefaultMutableTreeNode rootNode,
                                  int rootObjectNumber)
/** Internal use method (noop). Do not use.


beginPage

public void beginPage(Rectangle2D pageSize,
                      int pageNumber)
Starts a page; create the correct initial transformation and initialise the page resources lists.

Overrides:
beginPage in class JCPrinter
Parameters:
pageSize - the dimensions of this page
pageNumber - the number of this page in the document

endPage

public void endPage(Rectangle2D pageSize)
Complete the page (terminate the contents stream, write out the Page object including all resources used on the page.

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

writeResourcesDictionary

protected void writeResourcesDictionary()
Write a Resources Dictionary based on the current StreamInfo.


createNecessaryFontObjects

protected void createNecessaryFontObjects(Hashtable thisFontList)
Given a List of font names, created the necessary font entry objects and store them in the master font list.


writeResourcesFontList

protected void writeResourcesFontList(Hashtable thisFontList)
Write the Font list entry of a Resources dictionary.


writeResourcesPatternList

protected void writeResourcesPatternList()

getGraphics

public Graphics getGraphics()
Gets the graphics context used by this printer.

Overrides:
getGraphics in class JCPrinter
Returns:
A graphics context that outputs to this printer

supportsHyperlinks

public boolean supportsHyperlinks()
Returns true if this printer supports hyperlinks.

Overrides:
supportsHyperlinks in class JCPrinter
Returns:
false - Hyperlinks are not supported.

writePatternDescription

protected void writePatternDescription(JCPDFPrinter.PatternInfo patternInfo)

writeFontDescription

protected void writeFontDescription(com.klg.jclass.page.adobe.pdf.AcroFontEntry fontEntry)
Writes the font description to the output.

Parameters:
fontEntry - A FontEntry object describing a font used in the document

writeFontDescriptor

protected void writeFontDescriptor(int fontDescriptorObjectNumber,
                                   com.klg.jclass.page.adobe.pdf.AcroFontEntry fontEntry,
                                   com.klg.jclass.page.adobe.postscript.FontPS font,
                                   String fontNameInDescriptor)
Write the actual PDF Font Descriptor to the output.

Parameters:
fontDescriptorObjectNumber - object number of this font descriptor
fontEntry - AcroFontEntry object encapsulating font information for PDF output
font - FontPS class representing actual font
fontNameInDescriptor - name to use for the font in the descriptor. If font is embedded, this will be different than the usual name of the font to preserve uniqueness.

writeToUnicodeCMap

protected void writeToUnicodeCMap(int toUnicodeObjectNumber,
                                  com.klg.jclass.page.adobe.pdf.AcroFontEntry fontEntry,
                                  com.klg.jclass.page.adobe.postscript.FontPS font)
Write a ToUnicode CMap as a stream object.


formatHexString

public String formatHexString(int value,
                              int numChars)
Format an integer as a hex string, padding the beginning of the string with zeroes until it is the requested number of characters.


writeCompressedStreamObject

protected void writeCompressedStreamObject(int streamObjectNumber,
                                           ByteArrayOutputStream byteArrayOS,
                                           String extraEntries)
Write a compressed stream object to the output. Compression is done using Flate, and the resulting stream is then put through the Ascii85 Encoder.

Parameters:
streamObjectNumber - number reference of the stream object
byteArrayOS - contents of the stream as a ByteArrayOutputStream
extraEntries - extra entries (other than Filter and Length) for the descriptor that precedes the stream

writeCompressedStreamObject

protected void writeCompressedStreamObject(int streamObjectNumber,
                                           byte[] byteArray,
                                           String extraEntries)
Write a compressed stream object to the output. Compression is done using Flate, and the resulting stream is then put through the Ascii85 Encoder.

Parameters:
streamObjectNumber - number reference of the stream object
byteArray - contents of the stream as an array of bytes
extraEntries - extra entries (other than Filter and Length) for the descriptor that precedes the stream

writeCompressedStreamHeader

protected void writeCompressedStreamHeader(int streamObjectNumber,
                                           int streamLengthObjectNumber,
                                           String extraEntries)
Write the beginning of a compressed stream object to the output, including the filter specifications and the stream command. Compression will be done using Flate, and the resulting stream will also put through the Ascii85 Encoder.

Parameters:
streamObjectNumber - number reference of the stream object
streamLengthObjectNumber - number reference of the stream length object
extraEntries - extra entries (other than Filter and Length) for the descriptor that precedes the stream

writeCompressedStreamBody

protected int writeCompressedStreamBody(byte[] byteArray)
Write the body (i.e. the actual stream portion) of a compressed stream object to the output. Compression is done using Flate, and the resulting stream is then put through the Ascii85 Encoder.

Parameters:
byteArray - array of bytes to write to stream
Returns:
length of stream written to output

writeCompressedStreamFooter

protected void writeCompressedStreamFooter(int streamLengthObjectNumber,
                                           int streamLength)
Write the tail end of a compressed stream object to the output, including the endstream/endjob commands and an object containing the stream length.

Parameters:
streamLengthObjectNumber - number reference of the stream length object
streamLength - length of the preceding stream

writeUncompressedStreamObject

protected void writeUncompressedStreamObject(int streamObjectNumber,
                                             String contents,
                                             String extraEntries)
Write uncompressed (text) stream object to the output.

Parameters:
streamObjectNumber - number reference of the stream object
contents - contents of the stream
extraEntries - extra entries (other than Filter and Length) for the descriptor that precedes the stream

writeUncompressedStreamHeader

protected void writeUncompressedStreamHeader(int streamObjectNumber,
                                             int streamLengthObjectNumber,
                                             String extraEntries)
Write the beginning of an uncompressed stream object to the output, including the stream command.

Parameters:
streamObjectNumber - number reference of the stream object
streamLengthObjectNumber - number reference of the stream length object
extraEntries - extra entries (other than Filter and Length) for the descriptor that precedes the stream

writeUncompressedStreamFooter

protected void writeUncompressedStreamFooter(int streamLengthObjectNumber,
                                             int streamLength)
Write the tail end of an uncompressed stream object to the output, including the endstream/endjob commands and an object containing the stream length.

Parameters:
streamLengthObjectNumber - number reference of the stream length object
streamLength - length of the preceding stream

writeCharRangeSameWidth

protected void writeCharRangeSameWidth(com.klg.jclass.page.adobe.postscript.FontPS font,
                                       int start,
                                       int end)
Write out character widths for a CID font descriptor in the format "startchar endchar width". All characters in the range are expected to have the same width.


writeCharRangeDiffWidth

protected void writeCharRangeDiffWidth(com.klg.jclass.page.adobe.postscript.FontPS font,
                                       int start,
                                       int end)
Write out character widths for a CID font descriptor in the format "startchar [width-1 width-2 ... width-n]".


writeFontEncoding

protected void writeFontEncoding()
Writes the encoding vector of the standard (ISO Latin1) character set.


writeDocGraphicsDictionary

protected void writeDocGraphicsDictionary()
Writes the encoding vector of the standard (ISO Latin1) character set.


writePagesTree

protected void writePagesTree(Rectangle2D pageSize)
Completes and write the pages tree. First we must complete and output the last Pages object that owns Page objects, then we write out the root Pages object. NOTE: This is a somewhat simplistic tree; all Page objects are owned by a Pages object one level down from the root. For now there is no tree balancing or optimisation done.

Parameters:
pageSize - The size of the last Page object

writePagesObject

protected void writePagesObject(int referenceNumber,
                                Vector childList,
                                int parent,
                                Rectangle2D pageSize)
Writes out a Pages object.

Parameters:
referenceNumber - The Pages object's reference number
childList - The List of Page/Pages objects below this Pages object
parent - The reference number of the parent Pages object
pageSize - The size of the Page objects under this Pages object

pageChanged

protected boolean pageChanged(Rectangle2D pageSize)
Determines if the page has changed, which would require a new Pages object to be started.

Parameters:
pageSize - the current page's size
Returns:
True if the current page's size is different from the last

isBaseFont

public boolean isBaseFont(String name)
Determines if a given font name represents one of the 3 standard (built-in) PDF font families.

Parameters:
name - the name of a font to check
Returns:
True if the font is a standard PDF font

switchToNewStream

protected void switchToNewStream()
Switch output to a buffered stream which will be collected and written out following the end of the current page stream. This method takes into account the lists of font and xobject resources that are needed for each stream.


switchBackToOldStream

protected void switchBackToOldStream()
Switch back to the previously used stream.


storeObjectReference

protected void storeObjectReference(int objNumber,
                                    long offset)
Stores the cross-reference table information about an object (number, offset).

Parameters:
objNumber - The number of the object
offset - The offset from the start of the file, in bytes

getCurrentOffset

protected long getCurrentOffset()
Gets the current offset into the output stream.

Returns:
The number of bytes currently written to the output

getStreamStart

protected long getStreamStart()
Gets the start (initial offset) of the current contents stream.

Returns:
The position (offset) of the start of the contents stream

setStreamStart

protected void setStreamStart()
Marks the start of a contents stream (at the current offset).


pad10

protected String pad10(long offset)
Zero-pad the given number (file offset) as a 10-digit decimal number

Parameters:
offset - The number to be padded to 10 digits
Returns:
The string representation of the number including pad digits

beginPageStream

protected void beginPageStream()
Begin a page stream. If compression turned on, collect output to later write as a compressed stream. endStream() should be called when all desired input has been written to the stream via the output() method.


beginNonPageStream

protected void beginNonPageStream()
Begin a non-page stream. In this case, the stream header must have already been written to the output. This stream begins by writing the word "stream". If compression turned on, collect output to later write as a compressed stream. endStream() should be called when all desired input has been written to the stream via the output() method.


endStream

protected void endStream()
End stream. If compression turned on, write out collected output as a compressed stream. beginPageStream() or beginNonPageStream() must have been called previously.


output

protected void output(String string)
Write the given string to the output, tracking the number of bytes written and adding a new-line at the end of the string.

Overrides:
output in class JCPrinter
Parameters:
string - The string to be output

output

protected void output(byte[] bytes)
Write the given byte array to the output, tracking the number of bytes written. Do *not* add a new line to the end of the byte array.

Overrides:
output in class JCPrinter
Parameters:
bytes - the byte array to be output

output

protected void output(byte[] bytes,
                      int off,
                      int len)
Write the specified subsection of the given byte array to the output, tracking the number of bytes written. Do *not* add a new line to the end of the byte array.

Overrides:
output in class JCPrinter
Parameters:
bytes - the byte array to be output
off - offset at which subsection to be written begins
len - length of subsection to be written

output

protected void output(byte oneByte)
Write the specified byte to the output, tracking the number of bytes written. Do *not* add a new line after the byte is written.

Overrides:
output in class JCPrinter
Parameters:
oneByte - the byte to output

getFontAbbreviation

protected String getFontAbbreviation(String fontName)
Gets the abbreviation for a given font name.

Parameters:
fontName - The name of a font
Returns:
The abbreviation assigned this font on this page

getFontEntry

protected com.klg.jclass.page.adobe.pdf.AcroFontEntry getFontEntry(String fontName)
Gets the AcroFontEntry class associated with the requested font

Parameters:
fontName - The name of a font
Returns:
The AcroFontEntry class associated with the requested font

addFontToList

protected void addFontToList(com.klg.jclass.page.adobe.postscript.FontPS font)
Adds a font to the document's list of fonts.

Parameters:
font - The font to be stored in the list

isCompressed

public boolean isCompressed()
Returns true if this printer will generate compressed output

Overrides:
isCompressed in class JCPrinter
Returns:
true if compression will be performed; false otherwise

setCompressed

public void setCompressed(boolean compress)
Sets whether or not this printer will generate compressed output. Default is true. Only one level of compression is available - it's either on or off.

Overrides:
setCompressed in class JCPrinter
Parameters:
compress - When true, causes PDF output to be compressed.

addPattern

protected void addPattern(String patternName,
                          BufferedImage img)

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