intarsys PDF library API

de.intarsys.pdf.pd
Class PDDocument

java.lang.Object
  extended by de.intarsys.pdf.pd.PDDocument
All Implemented Interfaces:
IAdditionalActionSupport, IAttributeSupport, ILocatorSupport

public class PDDocument
extends Object
implements IAdditionalActionSupport, IAttributeSupport, ILocatorSupport

The PD Level representation of a PDF Document. PD Level objects provide the PDF semantics on top of the COS objects.

A PDDocument object should not be shared between threads without thought. Some clients may store information along with the PDDocument extensions in a non thread safe manner.


Field Summary
static Set CATALOG_ACTION_TRIGGERS
           
static COSName CN_Perms_DocMDP
           
static COSName CN_Perms_UR
           
static COSName DK_OpenAction
           
static COSName DK_Perms
           
 
Fields inherited from interface de.intarsys.pdf.pd.IAdditionalActionSupport
DK_AA
 
Method Summary
 void addAction(PDAction action)
           
 void addOpenAction(PDAction newAction)
          Add a PDAction to be exceuted when this is opened.
 void addPageNode(PDPageNode newNode)
          Add a page object to this documents root page tree.
 void addPageNodeAfter(PDPageNode newNode, PDPageNode destination)
          Add a page object to this document after the designated page.
 void close()
          Close the document.
 PDDocument copyDeep()
          Make a deep copy of the receiver.
 COSDocument cosGetDoc()
          The COS level implementation of the document
 COSDictionary cosGetPermissionsDict()
          The permissions dictionary of the document.
 COSDictionary cosGetPieceInfoDict()
          The piece info dictionary of the document.
 COSDictionary cosGetURI()
          The uri dictionary of the document.
 void cosSetPermissionsDict(COSDictionary permsDict)
          Set the permissions dictionary of the document.
 void cosSetPieceInfoDict(COSDictionary dict)
          Set the piece info dictionary of the document.
 PDAcroForm createAcroForm()
          create an AcroForm in a PDF Document.
static PDDocument createFromCos(COSDocument doc)
          create a pd document based on a cos level object
static PDDocument createFromLocator(ILocator locator)
           
static PDDocument createNew()
          create a PDDocument from scratch
 PDPageTree createPageTree()
          create a new page tree for this document. tha page tree must still be added to the document or a page tree to get visible.
 IAccessPermissions getAccessPermissions()
          Simple delegate to COSDocument.getAccessPermissions()
 PDAcroForm getAcroForm()
          read an AcroForm from a PDF Document. return null if no AcroForm is available.
 PDAdditionalActions getAdditionalActions()
           
 List getAnnotations()
           
 PDApplicationData getApplicationData(String name)
           
 Object getAttribute(Object key)
          get an attribute from the context
 String getAuthor()
           
 COSCatalog getCatalog()
          lookup the catalog dictionary in a document
 CDSDate getCreationDate()
           
 String getCreationDateString()
           
 String getCreator()
           
 COSInfoDict getInfoDict()
          Get the info dictionary containing metadata.
 String getKeywords()
           
 ILocator getLocator()
          Return the ILocator that defines the physical resource location for the reciver.
 String getMetadata()
           
 CDSDate getModDate()
           
 String getModDateString()
           
 String getName()
           
 PDAction getOpenAction()
           
 PDOutline getOutline()
           
 PDOutputIntent getOutputIntent(COSName oiName)
           
 List getOutputIntents()
           
 PDPageTree getPageTree()
          return the documents root page tree
 PDSignature getPermissions(COSName key)
          Shortcut to a signature dictionary in the document permissions dictionary.
 String getProducer()
           
 String getSubject()
           
 Set getSupportedTriggerEvents()
           
 String getTitle()
           
 String getTrapped()
           
 EnumWriteMode getWriteModeHint()
          The write mode to be used when the document is written the next time.
 boolean isAppendOnly()
          true if the document has a flag to prefere incremental save.
 boolean isDirty()
           
 boolean isEncrypted()
          Lookup if this document is encrypted, means it has a security handler.
 boolean isNew()
           
 boolean isPreferIncrementalSave()
          true if the document should be saved in an incremental way only.
 boolean isReadOnly()
           
 boolean isSigned()
          true if the document contains digital signatures.
 COSObject lookupDestination(String name)
           
 void removeApplicationData(String name)
           
 Object removeAttribute(Object key)
          remove an attribute in the context
 void restore(ILocator locator)
           
 void save()
           
 void save(ILocator locator)
           
 void save(ILocator locator, Map options)
           
 void setAcroForm(PDAcroForm form)
          Set AcroForm in PDF Document.
 void setAdditionalActions(PDAdditionalActions actions)
           
 void setApplicationData(String name, PDApplicationData data)
           
 Object setAttribute(Object key, Object o)
          set the value of an attribute in the context
 void setAuthor(String value)
           
 void setCreationDateString(String value)
           
 void setCreator(String value)
           
 void setDocumentInfo(COSName name, String value)
           
 void setInfoDict(COSInfoDict infoDict)
          Set the info dictionary containing metadata.
 void setKeywords(String value)
           
 void setModDateString(String value)
           
 void setName(String name)
           
 void setOpenAction(PDAction newAction)
           
 void setOutline(PDOutline outline)
           
 void setPageTree(PDPageTree newTree)
           
 void setPermissions(COSName name, PDSignature signature)
           
 void setProducer(String value)
           
 void setSubject(String value)
           
 void setTitle(String value)
           
 void setTrapped(String value)
           
 void setWriteModeHint(EnumWriteMode writeMode)
          The write mode to be used when the document is written the next time.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CATALOG_ACTION_TRIGGERS

public static final Set CATALOG_ACTION_TRIGGERS

DK_OpenAction

public static final COSName DK_OpenAction

DK_Perms

public static final COSName DK_Perms

CN_Perms_DocMDP

public static final COSName CN_Perms_DocMDP

CN_Perms_UR

public static final COSName CN_Perms_UR
Method Detail

createFromCos

public static PDDocument createFromCos(COSDocument doc)
                                throws COSLoadException
create a pd document based on a cos level object

Parameters:
doc - COSDocument to base this PDDocument on
Returns:
A new PDDocument object.
Throws:
COSLoadException

createFromLocator

public static PDDocument createFromLocator(ILocator locator)
                                    throws IOException,
                                           COSLoadException
Throws:
IOException
COSLoadException

createNew

public static PDDocument createNew()
create a PDDocument from scratch

Returns:
A new PDDocument.

addAction

public void addAction(PDAction action)

addOpenAction

public void addOpenAction(PDAction newAction)
Add a PDAction to be exceuted when this is opened.

Parameters:
newAction - The new PDAction

addPageNode

public void addPageNode(PDPageNode newNode)
Add a page object to this documents root page tree.

Parameters:
newNode - The page to be added

addPageNodeAfter

public void addPageNodeAfter(PDPageNode newNode,
                             PDPageNode destination)
Add a page object to this document after the designated page.

Parameters:
newNode - the page to be added
destination - The page after the new one is inserted

close

public void close()
           throws IOException
Close the document. Accessing a documents content is undefined after close.

Throws:
IOException

copyDeep

public PDDocument copyDeep()
Make a deep copy of the receiver.

Returns:
the object copied recursively

cosGetDoc

public COSDocument cosGetDoc()
The COS level implementation of the document

Returns:
The underlying COSDocument

cosGetPermissionsDict

public COSDictionary cosGetPermissionsDict()
The permissions dictionary of the document.

Returns:
The permissions dictionary of the document.

cosGetPieceInfoDict

public COSDictionary cosGetPieceInfoDict()
The piece info dictionary of the document.

Returns:
The piece info dictionary of the document.

cosGetURI

public COSDictionary cosGetURI()
The uri dictionary of the document.

Returns:
The uri dictionary of the document.

cosSetPermissionsDict

public void cosSetPermissionsDict(COSDictionary permsDict)
Set the permissions dictionary of the document.

Parameters:
permsDict - the new permission dictionary

cosSetPieceInfoDict

public void cosSetPieceInfoDict(COSDictionary dict)
Set the piece info dictionary of the document.

Parameters:
dict - the new piece info dictionary

createAcroForm

public PDAcroForm createAcroForm()
create an AcroForm in a PDF Document.

Returns:
the acro form just created
Throws:
IllegalStateException

createPageTree

public PDPageTree createPageTree()
create a new page tree for this document. tha page tree must still be added to the document or a page tree to get visible.

Returns:
the PDPageTree created

getAccessPermissions

public IAccessPermissions getAccessPermissions()
Simple delegate to COSDocument.getAccessPermissions()

Returns:
document access permissions

getAcroForm

public PDAcroForm getAcroForm()
read an AcroForm from a PDF Document. return null if no AcroForm is available.

Returns:
the acro form of the document or null

getAdditionalActions

public PDAdditionalActions getAdditionalActions()
Specified by:
getAdditionalActions in interface IAdditionalActionSupport

getAnnotations

public List getAnnotations()

getApplicationData

public PDApplicationData getApplicationData(String name)

getAttribute

public Object getAttribute(Object key)
Description copied from interface: IAttributeSupport
get an attribute from the context

Specified by:
getAttribute in interface IAttributeSupport
Parameters:
key - the name of the attribute to get
Returns:
The value of the attribute to get

getAuthor

public String getAuthor()

getCatalog

public COSCatalog getCatalog()
lookup the catalog dictionary in a document

Returns:
the document catalog object

getCreationDate

public CDSDate getCreationDate()

getCreationDateString

public String getCreationDateString()

getCreator

public String getCreator()

getInfoDict

public COSInfoDict getInfoDict()
Get the info dictionary containing metadata.

Returns:
The info dictionary containing metadata.

getKeywords

public String getKeywords()

getLocator

public ILocator getLocator()
Description copied from interface: ILocatorSupport
Return the ILocator that defines the physical resource location for the reciver.

Specified by:
getLocator in interface ILocatorSupport
Returns:
Return the ILocator that defines the physical resource location for the reciver.

getMetadata

public String getMetadata()

getModDate

public CDSDate getModDate()

getModDateString

public String getModDateString()

getName

public String getName()

getOpenAction

public PDAction getOpenAction()

getOutline

public PDOutline getOutline()

getOutputIntent

public PDOutputIntent getOutputIntent(COSName oiName)

getOutputIntents

public List getOutputIntents()

getPageTree

public PDPageTree getPageTree()
return the documents root page tree

Returns:
the root page tree of the document

getPermissions

public PDSignature getPermissions(COSName key)
Shortcut to a signature dictionary in the document permissions dictionary. Valid keys are "DocMDP" and "UR". If the permissions dictionary doesn't exist, then null is returned. If no signature dictionary under the specified key exists, null is returned.

Parameters:
key - key which should be ether "DocMDP" or "UR"
Returns:
returns a signature dictionary referenced by the specified key or null if ether no permissions dictionary exists or no signature dictionary to the key exists.

getProducer

public String getProducer()

getSubject

public String getSubject()

getSupportedTriggerEvents

public Set getSupportedTriggerEvents()
Specified by:
getSupportedTriggerEvents in interface IAdditionalActionSupport

getTitle

public String getTitle()

getTrapped

public String getTrapped()

getWriteModeHint

public EnumWriteMode getWriteModeHint()
The write mode to be used when the document is written the next time. If defined this overrides any hint that is used when saving the document. The write mode is reset after each "save".

Returns:
The write mode to be used when the document is written.

isDirty

public boolean isDirty()

isEncrypted

public boolean isEncrypted()
Lookup if this document is encrypted, means it has a security handler.

Returns:
true if the document has an ISystemSecurityHandler

isNew

public boolean isNew()

isReadOnly

public boolean isReadOnly()

isPreferIncrementalSave

public boolean isPreferIncrementalSave()
true if the document should be saved in an incremental way only. This is for example the case when the document contains digital signatures.

Returns:
true if the document should be saved in an incremental way only.

isAppendOnly

public boolean isAppendOnly()
true if the document has a flag to prefere incremental save.

Returns:
true if the document should be saved in an incremental way only.

isSigned

public boolean isSigned()
true if the document contains digital signatures. This should be reflected in the SigFlags entry of the form - but who knows...

Returns:
true if the document contains digital signatures.

lookupDestination

public COSObject lookupDestination(String name)

removeApplicationData

public void removeApplicationData(String name)

removeAttribute

public Object removeAttribute(Object key)
Description copied from interface: IAttributeSupport
remove an attribute in the context

Specified by:
removeAttribute in interface IAttributeSupport
Parameters:
key - the name of the attribute to remove
Returns:
The previously associated object for key

restore

public void restore(ILocator locator)
             throws IOException,
                    COSLoadException
Throws:
IOException
COSLoadException

save

public void save()
          throws IOException
Throws:
IOException

save

public void save(ILocator locator)
          throws IOException
Throws:
IOException

save

public void save(ILocator locator,
                 Map options)
          throws IOException
Throws:
IOException

setAcroForm

public void setAcroForm(PDAcroForm form)
Set AcroForm in PDF Document.


setAdditionalActions

public void setAdditionalActions(PDAdditionalActions actions)
Specified by:
setAdditionalActions in interface IAdditionalActionSupport

setApplicationData

public void setApplicationData(String name,
                               PDApplicationData data)

setAttribute

public Object setAttribute(Object key,
                           Object o)
Description copied from interface: IAttributeSupport
set the value of an attribute in the context

Specified by:
setAttribute in interface IAttributeSupport
Parameters:
key - the name of the attribute to set
o - the new value the attribute
Returns:
The previously associated object for key

setAuthor

public void setAuthor(String value)

setCreationDateString

public void setCreationDateString(String value)

setCreator

public void setCreator(String value)

setDocumentInfo

public void setDocumentInfo(COSName name,
                            String value)

setInfoDict

public void setInfoDict(COSInfoDict infoDict)
Set the info dictionary containing metadata.

Parameters:
infoDict - The info dictionary containing metadata.

setKeywords

public void setKeywords(String value)

setModDateString

public void setModDateString(String value)

setName

public void setName(String name)

setOpenAction

public void setOpenAction(PDAction newAction)

setOutline

public void setOutline(PDOutline outline)

setPageTree

public void setPageTree(PDPageTree newTree)

setPermissions

public void setPermissions(COSName name,
                           PDSignature signature)

setProducer

public void setProducer(String value)

setSubject

public void setSubject(String value)

setTitle

public void setTitle(String value)

setTrapped

public void setTrapped(String value)

setWriteModeHint

public void setWriteModeHint(EnumWriteMode writeMode)
The write mode to be used when the document is written the next time. If defined this overrides any hint that is used when saving the document. The write mode is reset after each "save".

Parameters:
writeMode - The write mode to be used when the document is written.

intarsys PDF library API

Copyright © 2006 intarsys consulting GmbH. All Rights Reserved.