public class PDFDocument
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected PDFDeviceColorSpace |
colorspace
the colorspace (0=RGB, 1=CMYK)
|
protected java.util.List |
destinations
List of Destinations.
|
static java.lang.String |
ENCODING
the encoding to use when converting strings to PDF commandos.
|
protected PDFEncryption |
encryption
the documents encryption, if exists
|
protected java.util.List |
filespecs
List of FileSpecs.
|
protected java.util.Map |
filterMap
The filter map.
|
protected java.util.Map |
fontMap
the Font Map.
|
protected java.util.List |
functions
List of functions.
|
protected java.util.List |
gotoremotes
List of GoToRemotes.
|
protected java.util.List |
gotos
List of GoTos.
|
protected java.util.List |
gstates
List of PDFGState objects.
|
protected PDFInfo |
info
the /Info object
|
protected java.util.List |
links
List of Links.
|
protected java.util.List |
location
the character position of each object
|
protected int |
objectcount
the counter for object numbering
|
protected java.util.List |
objects
the objects themselves
|
protected int |
patternCount
the counter for Pattern name numbering (e.g.
|
protected java.util.List |
patterns
List of patterns.
|
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
|
protected PDFProfile |
pdfProfile
Indicates which PDF profiles are active (PDF/A, PDF/X etc.)
|
protected int |
pdfVersion
Indicates what PDF version is active
|
protected int |
position
the current character position
|
protected PDFResources |
resources
the /Resources object
|
protected PDFRoot |
root
the /Root object
|
protected int |
shadingCount
the counter for Shading name numbering
|
protected java.util.List |
shadings
List of shadings.
|
protected int |
xObjectCount
the counter for XObject numbering
|
protected java.util.Map |
xObjectsMap
the XObjects Map.
|
protected int |
xref
character position of xref table
|
Constructor and Description |
---|
PDFDocument(java.lang.String prod)
Creates an empty PDF document.
|
Modifier and Type | Method and Description |
---|---|
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 an 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 a object number and sets the parent of the
PDFObject to this PDFDocument.
|
static byte[] |
encode(java.lang.String text)
Converts text to a byte array for writing to a PDF file.
|
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 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()
Get 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()
Get the filter map used for filters in this document.
|
java.util.Map |
getFontMap()
Get 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 pdf info object for this document.
|
PDFOutline |
getOutlineRoot()
Get the root Outlines object.
|
PDFPages |
getPages()
Returns the PDFPages object associated with the root object.
|
PDFDeviceColorSpace |
getPDFColorSpace()
Get 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 PDF root object.
|
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)
write the entire document out
|
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)
Set the creation date of the document.
|
void |
setCreator(java.lang.String creator)
Set the creator of the document.
|
void |
setEncryption(PDFEncryptionParams params)
Enables PDF encryption.
|
void |
setFilterMap(java.util.Map map)
Set the filter map to use for filters in this document.
|
void |
setProducer(java.lang.String producer)
set the producer of the document
|
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 position
protected java.util.List location
protected int objectcount
protected java.util.List objects
protected int xref
protected int pdfVersion
protected PDFProfile pdfProfile
protected PDFRoot root
protected PDFInfo info
protected PDFResources resources
protected PDFEncryption encryption
protected PDFDeviceColorSpace colorspace
protected int patternCount
protected int shadingCount
protected int xObjectCount
protected java.util.Map xObjectsMap
protected java.util.Map fontMap
protected java.util.Map filterMap
protected java.util.List gstates
protected java.util.List functions
protected java.util.List shadings
protected java.util.List patterns
protected java.util.List links
protected java.util.List destinations
protected java.util.List filespecs
protected java.util.List gotoremotes
protected java.util.List gotos
public PDFDocument(java.lang.String prod)
prod
- the name of the producer of this pdf documentpublic int getPDFVersion()
public java.lang.String getPDFVersionString()
public PDFProfile getProfile()
public PDFFactory getFactory()
public boolean isEncodingOnTheFly()
public static byte[] encode(java.lang.String text)
text
- text to convert/encodepublic 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 topublic 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()
public PDFPages getPages()
public PDFRoot getRoot()
public PDFInfo getInfo()
public PDFObject registerObject(PDFObject obj)
obj
- PDFObject to addpublic void assignObjectNumber(PDFObject obj)
obj
- PDFObject to assign a number topublic void addObject(PDFObject obj)
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 objectprotected PDFShading findShading(PDFShading compare)
compare
- reference objectprotected PDFPattern findPattern(PDFPattern compare)
compare
- reference objectprotected PDFFont findFont(java.lang.String fontname)
fontname
- name of the fontprotected PDFDestination findDestination(PDFDestination compare)
compare
- reference object to use as search templateprotected PDFLink findLink(PDFLink compare)
compare
- reference object to use as search templateprotected PDFFileSpec findFileSpec(PDFFileSpec compare)
compare
- reference object to use as search templateprotected PDFGoToRemote findGoToRemote(PDFGoToRemote compare)
compare
- reference object to use as search templateprotected PDFGoTo findGoTo(PDFGoTo compare)
compare
- reference object to use as search templateprotected PDFGState findGState(PDFGState wanted, PDFGState current)
wanted
- requested featurescurrent
- currently active featurespublic 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 resolvejava.io.FileNotFoundException
- if the URI could not be resolvedpublic PDFImageXObject getImage(java.lang.String key)
key
- the image key to look forpublic PDFXObject getXObject(java.lang.String key)
key
- the XObject key to look forpublic 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)
res
- the PDF resource context to add to, may be nullimg
- the PDF image to addpublic PDFFormXObject addFormXObject(PDFResourceContext res, PDFStream cont, PDFReference formres, java.lang.String key)
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 objectpublic PDFOutline getOutlineRoot()
public PDFResources getResources()
public void output(java.io.OutputStream stream) throws java.io.IOException
stream
- the OutputStream to output the document tojava.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 tojava.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 tojava.io.IOException
- if there is an exception writing to the output streamCopyright 1999-2008 The Apache Software Foundation. All Rights Reserved.