|
JClass DesktopViews 6.3.0 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.klg.jclass.page.JCPrinter | +--com.klg.jclass.page.adobe.pdf.JCPDFPrinter
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 |
protected int objectNumber
protected int rootPagesReference
protected int totalPageCount
protected int pagesReference
protected int currentPageObjectNumber
protected int encodingObj
protected int graphicsDictionaryObj
protected Vector pageList
protected Vector pagesList
protected Vector contentsList
protected Vector annotationList
protected Hashtable fontList
protected Rectangle2D bounds
protected Rectangle2D oldPageSize
protected Rectangle2D currentPageSize
protected boolean docOpen
protected WeakHashMap imageCache
protected Vector docImageList
protected boolean useAutoStrokeAdjustment
protected int drawJavaComponentObjectNumber
protected int drawJavaComponentLengthObjectNumber
protected int drawJavaComponentResourcesObjectNumber
protected boolean drawingJavaComponent
protected Vector annotationRectangles
protected Vector hyperlinkInfoList
protected Hashtable hyperlinkObjects
protected TreeMap annoInternalLocations
protected Hashtable annoInternalPages
protected JCPDFPrinter.StreamInfo streamInfo
protected Stack streamStack
protected Vector pageXObjectReferences
protected Vector pageXObjectStreams
Constructor Detail |
public JCPDFPrinter(OutputStream os)
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.
os
- The OutputStream to which the PDF is writtenAFMParser
public JCPDFPrinter(OutputStream os, com.klg.jclass.page.FontParser parser, String jarLocation, String fileExtension, String fontMapFileName)
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.
os
- the OutputStream
to which formatted output
should be sentparser
- 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 filefileExtension
- the parser will turn files contained in "jarLocation"
ending with this extension into fontsfontMapFileName
- the user fontmap file; a file containing mappings
between font names and their aliasesAFMParser.AFMParser(java.lang.String)
Method Detail |
public void setOutputStream(OutputStream os)
JCPrinter
setOutputStream
in class JCPrinter
os
- the stream to which output will be writtenpublic void setAutoStrokeAdjustment(boolean useASA)
public boolean getAutoStrokeAdjustment()
public boolean isDocOpen()
public void setup()
setup
in class JCPrinter
public boolean isImageScalable()
isImageScalable
in class JCPrinter
public void openDocument(Rectangle2D pageSize)
openDocument
in class JCPrinter
pageSize
- The size of a default/first pagepublic void closeDocument(Rectangle2D pageSize)
closeDocument
in class JCPrinter
pageSize
- The size of the default/last pageprotected void outputBookmarkTree(DefaultMutableTreeNode rootNode, int rootObjectNumber)
public void beginPage(Rectangle2D pageSize, int pageNumber)
beginPage
in class JCPrinter
pageSize
- the dimensions of this pagepageNumber
- the number of this page in the documentpublic void endPage(Rectangle2D pageSize)
endPage
in class JCPrinter
pageSize
- the dimensions of the pageprotected void writeResourcesDictionary()
protected void createNecessaryFontObjects(Hashtable thisFontList)
protected void writeResourcesFontList(Hashtable thisFontList)
protected void writeResourcesPatternList()
public Graphics getGraphics()
getGraphics
in class JCPrinter
public boolean supportsHyperlinks()
supportsHyperlinks
in class JCPrinter
protected void writePatternDescription(JCPDFPrinter.PatternInfo patternInfo)
protected void writeFontDescription(com.klg.jclass.page.adobe.pdf.AcroFontEntry fontEntry)
fontEntry
- A FontEntry object describing a font used in the documentprotected void writeFontDescriptor(int fontDescriptorObjectNumber, com.klg.jclass.page.adobe.pdf.AcroFontEntry fontEntry, com.klg.jclass.page.adobe.postscript.FontPS font, String fontNameInDescriptor)
fontDescriptorObjectNumber
- object number of this font descriptorfontEntry
- AcroFontEntry object encapsulating
font information for PDF outputfont
- FontPS class representing actual fontfontNameInDescriptor
- 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.protected void writeToUnicodeCMap(int toUnicodeObjectNumber, com.klg.jclass.page.adobe.pdf.AcroFontEntry fontEntry, com.klg.jclass.page.adobe.postscript.FontPS font)
public String formatHexString(int value, int numChars)
protected void writeCompressedStreamObject(int streamObjectNumber, ByteArrayOutputStream byteArrayOS, String extraEntries)
streamObjectNumber
- number reference of the stream objectbyteArrayOS
- contents of the stream as a ByteArrayOutputStreamextraEntries
- extra entries (other than Filter and Length)
for the descriptor that precedes the streamprotected void writeCompressedStreamObject(int streamObjectNumber, byte[] byteArray, String extraEntries)
streamObjectNumber
- number reference of the stream objectbyteArray
- contents of the stream as an array of bytesextraEntries
- extra entries (other than Filter and Length)
for the descriptor that precedes the streamprotected void writeCompressedStreamHeader(int streamObjectNumber, int streamLengthObjectNumber, String extraEntries)
streamObjectNumber
- number reference of the stream objectstreamLengthObjectNumber
- number reference of the stream length objectextraEntries
- extra entries (other than Filter and Length)
for the descriptor that precedes the streamprotected int writeCompressedStreamBody(byte[] byteArray)
byteArray
- array of bytes to write to stream
protected void writeCompressedStreamFooter(int streamLengthObjectNumber, int streamLength)
streamLengthObjectNumber
- number reference of the stream length objectstreamLength
- length of the preceding streamprotected void writeUncompressedStreamObject(int streamObjectNumber, String contents, String extraEntries)
streamObjectNumber
- number reference of the stream objectcontents
- contents of the streamextraEntries
- extra entries (other than Filter and Length)
for the descriptor that precedes the streamprotected void writeUncompressedStreamHeader(int streamObjectNumber, int streamLengthObjectNumber, String extraEntries)
streamObjectNumber
- number reference of the stream objectstreamLengthObjectNumber
- number reference of the stream length objectextraEntries
- extra entries (other than Filter and Length)
for the descriptor that precedes the streamprotected void writeUncompressedStreamFooter(int streamLengthObjectNumber, int streamLength)
streamLengthObjectNumber
- number reference of the stream length objectstreamLength
- length of the preceding streamprotected void writeCharRangeSameWidth(com.klg.jclass.page.adobe.postscript.FontPS font, int start, int end)
protected void writeCharRangeDiffWidth(com.klg.jclass.page.adobe.postscript.FontPS font, int start, int end)
protected void writeFontEncoding()
protected void writeDocGraphicsDictionary()
protected void writePagesTree(Rectangle2D pageSize)
pageSize
- The size of the last Page objectprotected void writePagesObject(int referenceNumber, Vector childList, int parent, Rectangle2D pageSize)
referenceNumber
- The Pages object's reference numberchildList
- The List of Page/Pages objects below this Pages objectparent
- The reference number of the parent Pages objectpageSize
- The size of the Page objects under this Pages objectprotected boolean pageChanged(Rectangle2D pageSize)
pageSize
- the current page's size
public boolean isBaseFont(String name)
name
- the name of a font to check
protected void switchToNewStream()
protected void switchBackToOldStream()
protected void storeObjectReference(int objNumber, long offset)
objNumber
- The number of the objectoffset
- The offset from the start of the file, in bytesprotected long getCurrentOffset()
protected long getStreamStart()
protected void setStreamStart()
protected String pad10(long offset)
offset
- The number to be padded to 10 digits
protected void beginPageStream()
protected void beginNonPageStream()
protected void endStream()
protected void output(String string)
output
in class JCPrinter
string
- The string to be outputprotected void output(byte[] bytes)
output
in class JCPrinter
bytes
- the byte array to be outputprotected void output(byte[] bytes, int off, int len)
output
in class JCPrinter
bytes
- the byte array to be outputoff
- offset at which subsection to be written beginslen
- length of subsection to be writtenprotected void output(byte oneByte)
output
in class JCPrinter
oneByte
- the byte to outputprotected String getFontAbbreviation(String fontName)
fontName
- The name of a font
protected com.klg.jclass.page.adobe.pdf.AcroFontEntry getFontEntry(String fontName)
fontName
- The name of a font
protected void addFontToList(com.klg.jclass.page.adobe.postscript.FontPS font)
font
- The font to be stored in the listpublic boolean isCompressed()
isCompressed
in class JCPrinter
true
if compression will be performed; false
otherwisepublic void setCompressed(boolean compress)
setCompressed
in class JCPrinter
compress
- When true, causes PDF output to be compressed.protected void addPattern(String patternName, BufferedImage img)
|
Copyright © 2004 Quest Software Inc.. All rights reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |