PJX

com.etymon.pjx
Class PdfManager

java.lang.Object
  extended bycom.etymon.pjx.PdfManager

public final class PdfManager
extends java.lang.Object

Manages the modification or creation of a PDF document. This class is synchronized.


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.
 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.
 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdfManager

public PdfManager(boolean init)
Constructs a 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.

Parameters:
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.

PdfManager

public PdfManager(PdfReader pdfReader)
           throws java.io.IOException,
                  PdfFormatException
Constructs a PdfManager representing an existing PDF document.

Parameters:
pdfReader - specifies the existing PDF document to read.
Throws:
java.io.IOException
PdfFormatException
Method Detail

getStartxref

public long getStartxref()
Deprecated. Do not use this method.


getReader

public PdfReader getReader()
Returns the PdfReader instance associated with this document.


addObject

public int addObject(PdfObject obj)
Adds a PDF object to the document and assigns a new object number to it.

Parameters:
obj - the PDF object to be added.
Returns:
the new object number assigned to the PDF object. The generation number of the object will be 0.

getObject

public PdfObject getObject(int objectNumber)
                    throws java.io.IOException,
                           PdfFormatException
Retrieves the PDF object associated with a specified object number.

Parameters:
objectNumber - specifies the object number of the PDF object to be retrieved.
Returns:
the retrieved PDF object.
Throws:
java.io.IOException
PdfFormatException

getObjectIndirect

public PdfObject getObjectIndirect(PdfObject obj)
                            throws java.io.IOException,
                                   PdfFormatException
Retrieves the PDF object referred to by a specified indirect reference object. If the specified object is not an indirect reference but a direct object, that object itself is returned. If the specified object is null, then null is returned.

Parameters:
obj - the indirect reference object (or direct object, or null).
Returns:
the retrieved object (or direct object).
Throws:
java.io.IOException
PdfFormatException

getTrailerDictionary

public PdfDictionary getTrailerDictionary()
Returns the document's trailer dictionary.

Returns:
the trailer dictionary.

getXrefTableSize

public 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.

Returns:
the size of the cross-reference table.

setObject

public void setObject(PdfObject obj,
                      int objectNumber)
Adds a PDF object to the document and assigns the specified object number to it. If an object in the document is already assigned to the specified object number, that object is replaced with the new one.

Parameters:
obj - the PDF object to be added.
objectNumber - the object number to assign to the PDF object.

setTrailerDictionary

public void setTrailerDictionary(PdfDictionary dictionary)
Assigns the document a new trailer dictionary, replacing the existing one (if any).

Parameters:
dictionary - specifies the new trailer dictionary.

writeDocument

public long writeDocument(PdfWriter pdfWriter)
                   throws java.io.IOException,
                          PdfFormatException
Writes the document in PDF format, including all modifications made through this 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.

Parameters:
pdfWriter - specifies the PDF document to write.
Returns:
the number of bytes written.
Throws:
java.io.IOException
PdfFormatException

writeDocument

public long writeDocument(PdfWriter pdfWriter,
                          boolean useIncrementalUpdate)
                   throws java.io.IOException,
                          PdfFormatException
Writes the document in PDF format, including all modifications made through this 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.

Parameters:
pdfWriter - specifies the PDF document to write.
useIncrementalUpdate - specifies whether incremental update format should be used. A value of true enables incremental update.
Returns:
the number of bytes written.
Throws:
java.io.IOException
PdfFormatException

Copyright © 1998-2004 Etymon Systems, Inc.

The PDF data structures, operators, and specification are
Copyright © 1985-2004 Adobe Systems Incorporated.