org.pdfbox.pdmodel.interactive.form
Class PDAcroForm
java.lang.Object
org.pdfbox.pdmodel.interactive.form.PDAcroForm
- COSObjectable
public class PDAcroForm
extends java.lang.Object
This class represents the acroform of a PDF document.
PDAcroForm
public PDAcroForm(PDDocument doc)
Constructor.
doc
- The document that this form is part of.
PDAcroForm
public PDAcroForm(PDDocument doc,
COSDictionary form)
Constructor.
doc
- The document that this form is part of.form
- The existing acroForm.
exportFDF
public FDFDocument exportFDF()
throws IOException
This will export all FDF form data.
- An FDF document used to export the document.
getDefaultResources
public PDResources getDefaultResources()
This will get the default resources for the acro form.
getDictionary
public COSDictionary getDictionary()
This will get the dictionary that this form wraps.
- The dictionary for this form.
getDocument
public PDDocument getDocument()
This will get the document associated with this form.
getField
public PDField getField(String name)
throws IOException
This will get a field by name, possibly using the cache if setCache is true.
name
- The name of the field to get.
- The field with that name of null if one was not found.
getFields
public List getFields()
throws IOException
This will return all of the fields in the document. The type
will be a org.pdfbox.pdmodel.field.PDField.
- A list of all the fields.
getXFA
public PDXFA getXFA()
Get the XFA resource, the XFA resource is only used for PDF 1.5+ forms.
- The xfa resource or null if it does not exist.
importFDF
public void importFDF(FDFDocument fdf)
throws IOException
This method will import an entire FDF document into the PDF document
that this acroform is part of.
fdf
- The FDF document to import.
isCachingFields
public boolean isCachingFields()
This will tell if this acro form is caching the fields.
- true if the fields are being cached.
setCacheFields
public void setCacheFields(boolean cache)
throws IOException
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.
cache
- A boolean telling if we should cache the fields.
setDefaultResources
public void setDefaultResources(PDResources dr)
This will set the default resources for the acroform.
dr
- The new default resources.
setFields
public void setFields(List fields)
Set the fields that are part of this AcroForm.
fields
- The fields that are part of this form.
setXFA
public void setXFA(PDXFA xfa)
Set the XFA resource, this is only used for PDF 1.5+ forms.