|
fop 1.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.fop.pdf.PDFDocument
public class PDFDocument
Class representing a PDF document. The document is built up by calling various methods and then finally output to given filehandle using output method. A PDF document consists of a series of numbered objects preceded by a header and followed by an xref table and trailer. The xref table allows for quick access to objects by listing their character positions within the document. For this reason the PDF document must keep track of the character position of each object. The document also keeps direct track of the /Root, /Info and /Resources objects. Modified by Mark Lillywhite, mark-fop@inomial.com. The changes involve: ability to output pages one-at-a-time in a streaming fashion (rather than storing them all for output at the end); ability to write the /Pages object after writing the rest of the document; ability to write to a stream and flush the object list; enhanced trailer output; cleanups.
Field Summary | |
---|---|
static java.lang.String |
ENCODING
the encoding to use when converting strings to PDF commands |
protected int |
objectcount
the counter for object numbering |
static int |
PDF_VERSION_1_3
Integer constant to represent PDF 1.3 |
static int |
PDF_VERSION_1_4
Integer constant to represent PDF 1.4 |
Constructor Summary | |
---|---|
PDFDocument(java.lang.String prod)
Creates an empty PDF document. |
Method Summary | |
---|---|
void |
addDestination(PDFDestination destination)
Adds a destination to the document. |
PDFFormXObject |
addFormXObject(PDFResourceContext res,
PDFStream cont,
PDFReference formres,
java.lang.String key)
Add a form XObject to the PDF document. |
PDFImageXObject |
addImage(PDFResourceContext res,
PDFImage img)
Add an image to the PDF document. |
void |
addObject(PDFObject obj)
Adds a PDFObject to this document. |
void |
addTrailerObject(PDFObject obj)
Add trailer object. |
void |
applyEncryption(AbstractPDFStream stream)
Apply the encryption filter to a PDFStream if encryption is enabled. |
void |
assignObjectNumber(PDFObject obj)
Assigns the PDFObject an object number,
and sets the parent of the PDFObject to this document. |
static byte[] |
encode(java.lang.String text)
Converts text to a byte array for writing to a PDF file. |
void |
enforceLanguageOnRoot()
Makes sure a Lang entry has been set on the document catalog, setting it to a default value if necessary. |
protected PDFDestination |
findDestination(PDFDestination compare)
Finds a named destination. |
protected PDFFileSpec |
findFileSpec(PDFFileSpec compare)
Finds a file spec. |
protected PDFFont |
findFont(java.lang.String fontname)
Finds a font. |
protected PDFFunction |
findFunction(PDFFunction compare)
Looks through the registered functions to see if one that is equal to a reference object exists |
protected PDFGoTo |
findGoTo(PDFGoTo compare)
Finds a goto. |
protected PDFGoToRemote |
findGoToRemote(PDFGoToRemote compare)
Finds a goto remote. |
protected PDFGState |
findGState(PDFGState wanted,
PDFGState current)
Looks for an existing GState to use |
protected PDFLaunch |
findLaunch(PDFLaunch compare)
Finds a launch. |
protected PDFLink |
findLink(PDFLink compare)
Finds a link. |
protected PDFPattern |
findPattern(PDFPattern compare)
Find a previous pattern. |
protected PDFShading |
findShading(PDFShading compare)
Looks through the registered shadings to see if one that is equal to a reference object exists |
int |
getColorSpace()
Returns the color space. |
java.util.List |
getDestinationList()
Gets the list of named destinations. |
PDFDests |
getDests()
Gets the PDFDests object (which represents the /Dests entry). |
PDFEncryption |
getEncryption()
Returns the active Encryption object. |
PDFFactory |
getFactory()
Returns the factory for PDF objects. |
java.util.Map |
getFilterMap()
Returns the PDFFilter s map used for filters in this document. |
java.util.Map |
getFontMap()
Returns the font map for this document. |
protected java.lang.String |
getIDEntry()
|
PDFImageXObject |
getImage(java.lang.String key)
Deprecated. Use getXObject instead (so forms are treated in the same way) |
PDFInfo |
getInfo()
Get the PDFInfo object for this document. |
PDFOutline |
getOutlineRoot()
Get the root Outlines object. |
PDFPages |
getPages()
Returns the PDFPages object associated with the root object. |
PDFDeviceColorSpace |
getPDFColorSpace()
Returns the PDF color space object. |
int |
getPDFVersion()
|
java.lang.String |
getPDFVersionString()
|
PDFProfile |
getProfile()
|
PDFResources |
getResources()
Get the /Resources object for the document |
PDFRoot |
getRoot()
Get the PDFRoot object for this document. |
static java.io.Writer |
getWriterFor(java.io.OutputStream out)
Creates and returns a Writer object wrapping the given OutputStream. |
PDFXObject |
getXObject(java.lang.String key)
Get an XObject from the image map. |
boolean |
hasDestinations()
Gets whether the document has named destinations. |
boolean |
isEncodingOnTheFly()
Indicates whether stream encoding on-the-fly is enabled. |
boolean |
isEncryptionActive()
Indicates whether encryption is active for this PDF or not. |
void |
output(java.io.OutputStream stream)
Writes out the entire document |
void |
outputHeader(java.io.OutputStream stream)
Write the PDF header. |
void |
outputTrailer(java.io.OutputStream stream)
Write the trailer |
PDFObject |
registerObject(PDFObject obj)
Registers a PDFObject in this PDF document. |
protected java.io.InputStream |
resolveURI(java.lang.String uri)
Resolve a URI. |
void |
setColorSpace(int theColorspace)
Set the color space. |
void |
setCreationDate(java.util.Date date)
Sets the creation date of the document. |
void |
setCreator(java.lang.String creator)
Sets the creator of the document. |
void |
setEncryption(PDFEncryptionParams params)
Enables PDF encryption. |
void |
setFilterMap(java.util.Map map)
Sets the filter map to use for filters in this document. |
void |
setProducer(java.lang.String producer)
Sets the producer of the document. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int PDF_VERSION_1_3
public static final int PDF_VERSION_1_4
public static final java.lang.String ENCODING
protected int objectcount
Constructor Detail |
---|
public PDFDocument(java.lang.String prod)
prod
- the name of the producer of this pdf documentMethod Detail |
---|
public int getPDFVersion()
public java.lang.String getPDFVersionString()
public PDFProfile getProfile()
public PDFFactory getFactory()
PDFFactory
objectpublic boolean isEncodingOnTheFly()
true
if on-the-fly encoding is enabledpublic static byte[] encode(java.lang.String text)
text
- text to convert/encode
byte
arraypublic static java.io.Writer getWriterFor(java.io.OutputStream out)
flush()
the Writer after use or before writing directly to the
underlying OutputStream.
out
- the OutputStream to write to
public void setProducer(java.lang.String producer)
producer
- string indicating application producing the PDFpublic void setCreationDate(java.util.Date date)
date
- Date to be stored as creation date in the PDF.public void setCreator(java.lang.String creator)
creator
- string indicating application creating the documentpublic void setFilterMap(java.util.Map map)
map
- the map of filter lists for each stream typepublic java.util.Map getFilterMap()
PDFFilter
s map used for filters in this document.
public PDFPages getPages()
PDFPages
object associated with the root object.
PDFPages
objectpublic PDFRoot getRoot()
PDFRoot
object for this document.
PDFRoot
objectpublic void enforceLanguageOnRoot()
public PDFInfo getInfo()
PDFInfo
object for this document.
PDFInfo
objectpublic PDFObject registerObject(PDFObject obj)
PDFObject
in this PDF document.
The object is assigned a new object number.
obj
- PDFObject
to add
PDFObject
added (with its object number set)public void assignObjectNumber(PDFObject obj)
PDFObject
an object number,
and sets the parent of the PDFObject
to this document.
obj
- PDFObject
to assign a number topublic void addObject(PDFObject obj)
PDFObject
to this document.
The object MUST have an object number assigned.
obj
- PDFObject
to addpublic void addTrailerObject(PDFObject obj)
obj
- the PDF object to addpublic void applyEncryption(AbstractPDFStream stream)
stream
- PDFStream to encryptpublic void setEncryption(PDFEncryptionParams params)
params
- The encryption parameters for the pdf filepublic boolean isEncryptionActive()
public PDFEncryption getEncryption()
protected PDFFunction findFunction(PDFFunction compare)
compare
- reference object
protected PDFShading findShading(PDFShading compare)
compare
- reference object
protected PDFPattern findPattern(PDFPattern compare)
compare
- reference object
protected PDFFont findFont(java.lang.String fontname)
fontname
- name of the font
protected PDFDestination findDestination(PDFDestination compare)
compare
- reference object to use as search template
protected PDFLink findLink(PDFLink compare)
compare
- reference object to use as search template
protected PDFFileSpec findFileSpec(PDFFileSpec compare)
compare
- reference object to use as search template
protected PDFGoToRemote findGoToRemote(PDFGoToRemote compare)
compare
- reference object to use as search template
protected PDFGoTo findGoTo(PDFGoTo compare)
compare
- reference object to use as search template
protected PDFLaunch findLaunch(PDFLaunch compare)
compare
- reference object to use as search template
protected PDFGState findGState(PDFGState wanted, PDFGState current)
wanted
- requested featurescurrent
- currently active features
public PDFDeviceColorSpace getPDFColorSpace()
public int getColorSpace()
public void setColorSpace(int theColorspace)
theColorspace
- the new color spacepublic java.util.Map getFontMap()
protected java.io.InputStream resolveURI(java.lang.String uri) throws java.io.FileNotFoundException
uri
- the uri to resolve
java.io.FileNotFoundException
- if the URI could not be resolvedpublic PDFImageXObject getImage(java.lang.String key)
key
- the image key to look for
public PDFXObject getXObject(java.lang.String key)
key
- the XObject key to look for
public PDFDests getDests()
public void addDestination(PDFDestination destination)
destination
- the destination objectpublic java.util.List getDestinationList()
public boolean hasDestinations()
public PDFImageXObject addImage(PDFResourceContext res, PDFImage img)
PDFXObject
.
res
- the PDF resource context to add to, may be nullimg
- the PDF image to add
public PDFFormXObject addFormXObject(PDFResourceContext res, PDFStream cont, PDFReference formres, java.lang.String key)
PDFFormXObject
.
res
- the PDF resource context to add to, may be nullcont
- the PDF Stream contents of the Form XObjectformres
- a reference to the PDF Resources for the Form XObject datakey
- the key for the object
public PDFOutline getOutlineRoot()
public PDFResources getResources()
public void output(java.io.OutputStream stream) throws java.io.IOException
stream
- the OutputStream to output the document to
java.io.IOException
- if there is an exception writing to the output streampublic void outputHeader(java.io.OutputStream stream) throws java.io.IOException
stream
- the OutputStream to write the header to
java.io.IOException
- if there is an exception writing to the output streamprotected java.lang.String getIDEntry()
public void outputTrailer(java.io.OutputStream stream) throws java.io.IOException
stream
- the OutputStream to write the trailer to
java.io.IOException
- if there is an exception writing to the output stream
|
fop 1.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |