com.crionics.jpdf
Class PdfDocument

java.lang.Object
  extended by com.crionics.jpdf.PdfDocument

public class PdfDocument
extends java.lang.Object

Main jPDF class.
WARNING: DEPENDING ON YOUR LICENSE NOT ALL THESE FEATURES MAY BE ACTIVATED. The class contains all the mandatory methods to manipulate programmaticaly a pdf document. jPDF uses a per-file cache to optimize PDF parsing. The cache entries are purged by the JVM when it requires memory. You can force the cache cleanup by calling the close() method on the document or the method purgeCache(). Be very careful: if another process is updating the PDF file, you may find document/cache out of sync problems. Clear the cache wisely.


Field Summary
 PdfDoc document
           
 
Constructor Summary
PdfDocument()
          Creates a new PdfDocument in memory.
PdfDocument(byte[] buffer)
          Opens a the given document from a memory array
Note: When using this constructor the whole document will be held in memory.
PdfDocument(byte[] buffer, ICredentials credentials)
           
PdfDocument(byte[] buffer, Preferences prefs)
          Opens a the given document from a memory array
Note: When using this constructor the whole document will be held in memory.
PdfDocument(ByteReader reader)
          Opens the given PDF document.
PdfDocument(ByteReader reader, ICredentials credentials)
          Opens the document from the specified reader using the given reader and credentials.
PdfDocument(ByteReader reader, Preferences prefs)
          PdfDocument constructor. which takes a ByteReader and the default pdf preferences to use during the generation.
PdfDocument(java.io.File file)
          Opens the given PDF document.
PdfDocument(java.io.File file, ICredentials credentials)
           
PdfDocument(java.io.File file, Preferences prefs)
          Opens the given file using the given generation preferences.
PdfDocument(Preferences preferences)
          Creates a new PdfDocument object using the given PDF generation preferences.
PdfDocument(java.lang.String filename)
          PdfDocument constructor which takes a pdf filename as an argument.
PdfDocument(java.lang.String filename, ICredentials credentials)
          Opens the given document uctor which takes a ByteReader and the User or Owner password as arguments.
PdfDocument(java.lang.String filename, Preferences prefs)
          PdfDocument constructor which takes a pdf filename and the User or Owner password as arguments.
 
Method Summary
 void addOpenAction(AbstractAction action)
          Sets the action to perform when the document is opened.
 void clearOpenAction()
          Clears the list of actions to perform when the document is opened
 void close()
          Frees up all resources associated with the document Cleans up internal structures and cache entries for this document.
 AbstractAction getBeforeClosingDocumentActions()
          Returns the actions performed when the document is closed
 CreatorModule getCreatorModule()
          Return the the Creator Module.
 PdfDocumentDescription getDescription()
          Returns information about the document
 EncryptionModule getEncryptionModule()
          Return the the Encryption Module.
 MergerModule getMergerModule()
          Return the the Merger Module.
 AbstractAction getOnBeforeDocumentOpenAction()
          Returns the actions performed when the document is opened
 int getPageCount()
          Returns the number of pages in the document
 Preferences getPreferences()
          Returns the preferences for this document.
 PrinterModule getPrinterModule()
          Return the the Printer Module.
 PdfDocumentSecurity getSecurity()
          Returns the security handler which can be used to check access permissions to the document content
 SignerModule getSignerModule()
          Return the the Signer Module.
 TemplateModule getTemplateModule()
          Return the the Template Module.
 boolean isUpdated()
          Returns true if data (due to document modifications) were appended to the document
 void purgeCache()
          Purges the document cache.
 void save()
          Incrementally updates the document. extremely fast as it only appends the changes.
 void saveAs(java.io.File fileDest)
          Incrementally saves the document to a new destination.
 void saveAs(java.lang.String fileDest)
          Incrementally saves the document to a new destination.
 void saveAsNew(java.io.File fileDest)
          Saves the document as a new document.
 void saveAsNew(java.lang.String fileDest)
          Saves the document as a new document. optimizes the pdf to remove unused incremental updates (if any).
 void saveCopy(java.io.File file)
          Saves the current document along all the updates to a new location.
 void saveCopy(java.io.OutputStream os)
          Saves the current document along all the updates to a new location.
 void saveCopy(java.lang.String filename)
          Saves the updated document to a new location.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

document

public PdfDoc document
Constructor Detail

PdfDocument

public PdfDocument()
            throws java.io.IOException,
                   PdfException
Creates a new PdfDocument in memory. The document can be saved to disk using the methods saveAs(), saveCopy() or saveAsNew()

Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

PdfDocument

public PdfDocument(byte[] buffer)
            throws java.io.IOException,
                   PdfException
Opens a the given document from a memory array
Note: When using this constructor the whole document will be held in memory. Please avoid using this constructor, jPDF integrates a fast caching algorithm which will give excellent performances and optimize memory resources.

Parameters:
buffer - The byte array containing the document.
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

PdfDocument

public PdfDocument(byte[] buffer,
                   ICredentials credentials)
            throws java.io.IOException,
                   PdfException
Throws:
java.io.IOException
PdfException

PdfDocument

public PdfDocument(byte[] buffer,
                   Preferences prefs)
            throws java.io.IOException,
                   PdfException
Opens a the given document from a memory array
Note: When using this constructor the whole document will be held in memory. Please avoid using this constructor, jPDF integrates a fast caching algorithm which will give excellent performances and optimize memory resources.

Parameters:
buffer - The byte array containing the document.
prefs - the preferences used to generate the document
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

PdfDocument

public PdfDocument(ByteReader reader)
            throws java.io.IOException,
                   PdfException
Opens the given PDF document. ByteReaders can be used to customize how and where the pdf is read from.

Parameters:
reader - The bytereader.
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

PdfDocument

public PdfDocument(ByteReader reader,
                   ICredentials credentials)
            throws java.io.IOException,
                   PdfException
Opens the document from the specified reader using the given reader and credentials. Credentials can be a password or a certificate.

Parameters:
reader - a bytereader representing the PDF document
credentials - a password or a certificate.
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

PdfDocument

public PdfDocument(ByteReader reader,
                   Preferences prefs)
            throws java.io.IOException,
                   PdfException
PdfDocument constructor. which takes a ByteReader and the default pdf preferences to use during the generation.

Parameters:
reader - The bytereader.
prefs - the preferences used to generate the document
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

PdfDocument

public PdfDocument(java.io.File file)
            throws java.io.IOException,
                   PdfException
Opens the given PDF document.

Parameters:
file - The PDF File to open.
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

PdfDocument

public PdfDocument(java.io.File file,
                   ICredentials credentials)
            throws java.io.IOException,
                   PdfException
Throws:
java.io.IOException
PdfException

PdfDocument

public PdfDocument(java.io.File file,
                   Preferences prefs)
            throws java.io.IOException,
                   PdfException
Opens the given file using the given generation preferences.

Parameters:
file - The PDF File to open.
prefs - the preferences used to generate the document
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

PdfDocument

public PdfDocument(Preferences preferences)
            throws java.io.IOException,
                   PdfException
Creates a new PdfDocument object using the given PDF generation preferences.

Parameters:
preferences - the preferences used to generate the document
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

PdfDocument

public PdfDocument(java.lang.String filename)
            throws java.io.IOException,
                   PdfException
PdfDocument constructor which takes a pdf filename as an argument.
Note: Please use the '/' path delimitor as it is 100% compatible from one platform to another.

Parameters:
filename - The PDF file to open.
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

PdfDocument

public PdfDocument(java.lang.String filename,
                   ICredentials credentials)
            throws java.io.IOException,
                   PdfException
Opens the given document uctor which takes a ByteReader and the User or Owner password as arguments. ByteReaders can be used to customize how and where the pdf is read from.

Parameters:
reader - The bytereader.
prefs - the preferences used to generate the document
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

PdfDocument

public PdfDocument(java.lang.String filename,
                   Preferences prefs)
            throws java.io.IOException,
                   PdfException
PdfDocument constructor which takes a pdf filename and the User or Owner password as arguments.
Note: Please use the / path delimitor as it is 100% compatible from one platform to another.

Parameters:
filename - The PDF Filename.
prefs - the preferences used to generate the document
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.
Method Detail

addOpenAction

public void addOpenAction(AbstractAction action)
                   throws java.io.IOException,
                          PdfException
Sets the action to perform when the document is opened.

Parameters:
action - - the action to perform when the document is opened
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

clearOpenAction

public void clearOpenAction()
                     throws java.io.IOException,
                            PdfException
Clears the list of actions to perform when the document is opened

Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

close

public void close()
           throws java.io.IOException
Frees up all resources associated with the document Cleans up internal structures and cache entries for this document.

Throws:
java.io.IOException - Raised if a problem occured while reading the file.

getBeforeClosingDocumentActions

public AbstractAction getBeforeClosingDocumentActions()
                                               throws java.io.IOException,
                                                      PdfException
Returns the actions performed when the document is closed

Returns:
null or the action
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

getCreatorModule

public CreatorModule getCreatorModule()
Return the the Creator Module. Use this module to create/modify PDF documents. Methods in the modules may be restricted depending on your license

Returns:
The Creator Module.

getDescription

public PdfDocumentDescription getDescription()
Returns information about the document

Returns:
information about the document

getEncryptionModule

public EncryptionModule getEncryptionModule()
Return the the Encryption Module. Use this module to encrypt and decrypt documents.

Returns:
The Encryption Module.

getMergerModule

public MergerModule getMergerModule()
Return the the Merger Module. Use this module to merge/split PDF documents.

Returns:
The Merger Module.

getOnBeforeDocumentOpenAction

public AbstractAction getOnBeforeDocumentOpenAction()
                                             throws java.io.IOException,
                                                    PdfException
Returns the actions performed when the document is opened

Returns:
null or the action
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

getPageCount

public int getPageCount()
Returns the number of pages in the document

Returns:
The number of pages in the document

getPreferences

public Preferences getPreferences()
Returns the preferences for this document. Preferences are used to set static and dynamic PDF attributs.

Returns:
The PDF generation preferences

getPrinterModule

public PrinterModule getPrinterModule()
Return the the Printer Module. Use this module to print document to gfx or printers.

Returns:
The Printer Module.

getSecurity

public PdfDocumentSecurity getSecurity()
Returns the security handler which can be used to check access permissions to the document content

Returns:
the security handler

getSignerModule

public SignerModule getSignerModule()
Return the the Signer Module. Use this module to validate and create digital signatures

Returns:
The Signer Module.

getTemplateModule

public TemplateModule getTemplateModule()
Return the the Template Module. Use this module to access fields and pictures.

Returns:
The Template Module.

isUpdated

public boolean isUpdated()
Returns true if data (due to document modifications) were appended to the document

Returns:
true - if document contains updates

purgeCache

public void purgeCache()
Purges the document cache.
Note: If another process is updating the PDF file, you may find document/cache outofsync problems.


save

public void save()
          throws java.io.IOException,
                 PdfException
Incrementally updates the document. extremely fast as it only appends the changes.

Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

saveAs

public void saveAs(java.io.File fileDest)
            throws java.io.IOException,
                   PdfException
Incrementally saves the document to a new destination. After completion, the document instance points at the new document and all upcoming changes are saved to the specified destination.

Parameters:
fileDest - The new destination of the document.
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

saveAs

public void saveAs(java.lang.String fileDest)
            throws java.io.IOException,
                   PdfException
Incrementally saves the document to a new destination. All the changes in the document made after this call will be saved to the specified destination.

Parameters:
fileDest - The new destination of the document.
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

saveAsNew

public void saveAsNew(java.io.File fileDest)
               throws java.io.IOException,
                      PdfException
Saves the document as a new document. All unused incremental updates (if any) are discarded. This typically results in smaller document - at the expense of a heavier save delay. All the changes in the document made after this call will be save to the specified destination.

Parameters:
fileDest - The new destination of the document.
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

saveAsNew

public void saveAsNew(java.lang.String fileDest)
               throws java.io.IOException,
                      PdfException
Saves the document as a new document. optimizes the pdf to remove unused incremental updates (if any). This typically results in smaller document - at the expense of a heavier save delay. All the changes in the document made after this call will be save to the specified destination.

Parameters:
fileDest - The new destination of the document.
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

saveCopy

public void saveCopy(java.io.File file)
              throws java.io.IOException,
                     PdfException
Saves the current document along all the updates to a new location. After completion the current document is not affected

Parameters:
file - Destination File Object.
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

saveCopy

public void saveCopy(java.io.OutputStream os)
              throws java.io.IOException,
                     PdfException
Saves the current document along all the updates to a new location. After completion the current document is not affected

Parameters:
os - Destination output stream.
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.

saveCopy

public void saveCopy(java.lang.String filename)
              throws java.io.IOException,
                     PdfException
Saves the updated document to a new location.

Parameters:
filename - Destination file name.
Throws:
java.io.IOException - Raised if a problem occured while reading the file.
PdfException - Raised if a problem occured while parsing the file.


Copyright © 1999-2007 Crionics. All Rights Reserved.