Class PDAcroForm
java.lang.Object
org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm
- All Implemented Interfaces:
COSObjectable
This class represents the acroform of a PDF document.
- Version:
- $Revision: 1.14 $
- Author:
- Ben Litchfield
-
Constructor Summary
ConstructorsConstructorDescriptionPDAcroForm
(PDDocument doc) Constructor.PDAcroForm
(PDDocument doc, COSDictionary form) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionThis will export all FDF form data.Convert this standard java object to a COS object.This will get the default resources for the acro form.This will get the dictionary that this form wraps.This will get the document associated with this form.This will get a field by name, possibly using the cache if setCache is true.This will return all of the documents root fields.getXFA()
Get the XFA resource, the XFA resource is only used for PDF 1.5+ forms.void
importFDF
(FDFDocument fdf) This method will import an entire FDF document into the PDF document that this acroform is part of.boolean
This will tell if this acro form is caching the fields.void
setCacheFields
(boolean cache) This will tell this form to cache the fields into a Map structure for fast access via the getField method.void
This will set the default resources for the acroform.void
Set the documents root fields.void
Set the XFA resource, this is only used for PDF 1.5+ forms.
-
Constructor Details
-
PDAcroForm
Constructor.- Parameters:
doc
- The document that this form is part of.
-
PDAcroForm
Constructor.- Parameters:
doc
- The document that this form is part of.form
- The existing acroForm.
-
-
Method Details
-
getDocument
This will get the document associated with this form.- Returns:
- The PDF document.
-
getDictionary
This will get the dictionary that this form wraps.- Returns:
- The dictionary for this form.
-
importFDF
This method will import an entire FDF document into the PDF document that this acroform is part of.- Parameters:
fdf
- The FDF document to import.- Throws:
IOException
- If there is an error doing the import.
-
exportFDF
This will export all FDF form data.- Returns:
- An FDF document used to export the document.
- Throws:
IOException
- If there is an error when exporting the document.
-
getFields
This will return all of the documents root fields. A field might have children that are fields (non-terminal field) or does not have children which are fields (terminal fields). The fields within an AcroForm are organized in a tree structure. The documents root fields might either be terminal fields, non-terminal fields or a mixture of both. Non-terminal fields mark branches which contents can be retrieved usingPDFieldTreeNode#getKids()
.- Returns:
- A list of the documents root fields.
- Throws:
IOException
-
setFields
Set the documents root fields.- Parameters:
fields
- The fields that are part of the documents root fields.
-
setCacheFields
This will tell this form to cache the fields into a Map structure for fast access via the getField method. The default is false. You would want this to be false if you were changing the COSDictionary behind the scenes, otherwise setting this to true is acceptable.- Parameters:
cache
- A boolean telling if we should cache the fields.- Throws:
IOException
- If there is an error while caching the fields.
-
isCachingFields
public boolean isCachingFields()This will tell if this acro form is caching the fields.- Returns:
- true if the fields are being cached.
-
getField
This will get a field by name, possibly using the cache if setCache is true.- Parameters:
name
- The name of the field to get.- Returns:
- The field with that name of null if one was not found.
- Throws:
IOException
- If there is an error getting the field type.
-
getDefaultResources
This will get the default resources for the acro form.- Returns:
- The default resources.
-
setDefaultResources
This will set the default resources for the acroform.- Parameters:
dr
- The new default resources.
-
getCOSObject
Convert this standard java object to a COS object.- Specified by:
getCOSObject
in interfaceCOSObjectable
- Returns:
- The cos object that matches this Java object.
-
getXFA
Get the XFA resource, the XFA resource is only used for PDF 1.5+ forms.- Returns:
- The xfa resource or null if it does not exist.
-
setXFA
Set the XFA resource, this is only used for PDF 1.5+ forms.- Parameters:
xfa
- The xfa resource.
-