|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.etymon.pjx.PdfManager
public final class PdfManager
Manages the modification or creation of a PDF document. This class is synchronized.
Field Summary | |
---|---|
protected long |
_last_startxref
|
protected java.util.Map |
_modobj
The collection of PDF objects that have been modified. |
protected int |
_modsize
The total size of the cross-reference table, taking together both the PDF input document and the modified objects. |
protected PdfReader |
_reader
The PDF input document. |
protected long |
_startxref
The beginning offset of the cross-reference table in the PDF input document. |
protected PdfDictionary |
_trailer
The document's trailer dictionary, in its current (possibly modified) state. |
protected XrefTable |
_xt
The cross-reference table and associated trailer read from the PDF input document. |
protected static PdfName |
PDFNAME_PREV
|
protected static PdfName |
PDFNAME_SIZE
|
Constructor Summary | |
---|---|
PdfManager(boolean init)
Constructs a PdfManager representing an empty
PDF document. |
|
PdfManager(PdfReader pdfReader)
Constructs a PdfManager representing an
existing PDF document. |
Method Summary | |
---|---|
int |
addObject(PdfObject obj)
Adds a PDF object to the document and assigns a new object number to it. |
protected void |
construct()
Performs initialization common to multiple constructors of this class. |
PdfObject |
getObject(int objectNumber)
Retrieves the PDF object associated with a specified object number. |
PdfObject |
getObjectIndirect(PdfObject obj)
Retrieves the PDF object referred to by a specified indirect reference object. |
PdfReader |
getReader()
Returns the PdfReader instance associated with
this document. |
long |
getStartxref()
Deprecated. Do not use this method. |
PdfDictionary |
getTrailerDictionary()
Returns the document's trailer dictionary. |
int |
getXrefTableSize()
Returns the current size of the cross-reference table, taking into account any modifications that have been made to the document via this PdfManager. |
private void |
initialize()
Creates the minimal set of objects in a newly constructed document in order to create a single blank page. |
void |
setObject(PdfObject obj,
int objectNumber)
Adds a PDF object to the document and assigns the specified object number to it. |
void |
setTrailerDictionary(PdfDictionary dictionary)
Assigns the document a new trailer dictionary, replacing the existing one (if any). |
long |
writeDocument(PdfWriter pdfWriter)
Writes the document in PDF format, including all modifications made through this PdfManager . |
long |
writeDocument(PdfWriter pdfWriter,
boolean useIncrementalUpdate)
Writes the document in PDF format, including all modifications made through this PdfManager . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected long _last_startxref
protected static final PdfName PDFNAME_PREV
protected static final PdfName PDFNAME_SIZE
protected java.util.Map _modobj
protected int _modsize
protected PdfReader _reader
protected long _startxref
protected PdfDictionary _trailer
protected XrefTable _xt
Constructor Detail |
---|
public PdfManager(boolean init)
PdfManager
representing an empty
PDF document. The document in this initial state contains
no objects and therefore does not correspond to a valid PDF
file.
init
- if false, specifies that the document contain
no objects (and therefore will not correspond to a valid
PDF file); if true, that the document be initialized with
a minimal set of objects to create a single blank page.public PdfManager(PdfReader pdfReader) throws java.io.IOException, PdfFormatException
PdfManager
representing an
existing PDF document.
pdfReader
- specifies the existing PDF document to
read.
java.io.IOException
PdfFormatException
Method Detail |
---|
public long getStartxref()
public PdfReader getReader()
PdfReader
instance associated with
this document.
private void initialize()
public int addObject(PdfObject obj)
obj
- the PDF object to be added.
public PdfObject getObject(int objectNumber) throws java.io.IOException, PdfFormatException
objectNumber
- specifies the object number of the PDF
object to be retrieved.
java.io.IOException
PdfFormatException
public PdfObject getObjectIndirect(PdfObject obj) throws java.io.IOException, PdfFormatException
null
, then null
is returned.
obj
- the indirect reference object (or direct object,
or null
).
java.io.IOException
PdfFormatException
public PdfDictionary getTrailerDictionary()
public int getXrefTableSize()
protected void construct()
public void setObject(PdfObject obj, int objectNumber)
obj
- the PDF object to be added.objectNumber
- the object number to assign to the PDF
object.public void setTrailerDictionary(PdfDictionary dictionary)
dictionary
- specifies the new trailer dictionary.public long writeDocument(PdfWriter pdfWriter) throws java.io.IOException, PdfFormatException
PdfManager
.
This method is equivalent to using writeDocument(...,
true)
; i.e. it uses incremental update if applicable.
Note that this means the resultant document will be larger
than the original document; otherwise use writeDocument(...,
false)
to get a smaller resultant file, although it will
usually take longer to generate. The
PdfWriter
should be newly created (i.e. it
should not have been previously used for anything); and
after this method has been called, the
PdfWriter
should be closed and discarded.
pdfWriter
- specifies the PDF document to write.
java.io.IOException
PdfFormatException
public long writeDocument(PdfWriter pdfWriter, boolean useIncrementalUpdate) throws java.io.IOException, PdfFormatException
PdfManager
.
This method will optionally use PDF's incremental update
format, which often takes significantly less processing
time but creates a larger resultant PDF file and may be
slower for a reader to open (if the file has been updated
many times in this way). Incremental update should not be
used when the original document is a Linearized PDF file if
changes have been made that would invalidate its
correctness, unless the resultant PDF file will not be used
in an application that depends on its correct
Linearization. If this PdfManager
represents
a new document rather than modifying an existing one, then
the incremental update option is not applicable and is
disregarded. The PdfWriter
should be newly
created (i.e. it should not have been previously used for
anything); and after this method has been called, the
PdfWriter
should be closed and discarded.
pdfWriter
- specifies the PDF document to write.useIncrementalUpdate
- specifies whether incremental
update format should be used. A value of true
enables incremental update.
java.io.IOException
PdfFormatException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |