public final class PDAcroForm extends java.lang.Object implements COSObjectable
Modifier and Type | Field and Description |
---|---|
private COSDictionary |
dictionary |
private PDDocument |
document |
private java.util.Map<java.lang.String,PDField> |
fieldCache |
private static int |
FLAG_APPEND_ONLY |
private static int |
FLAG_SIGNATURES_EXIST |
private static org.apache.commons.logging.Log |
LOG |
Constructor and Description |
---|
PDAcroForm(PDDocument doc)
Constructor.
|
PDAcroForm(PDDocument doc,
COSDictionary form)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private java.util.Map<COSDictionary,java.util.Set<COSDictionary>> |
buildPagesWidgetsMap(java.util.List<PDField> fields) |
FDFDocument |
exportFDF()
This will export all FDF form data.
|
private void |
fillPagesAnnotationMap(java.util.Map<COSDictionary,java.util.Set<COSDictionary>> pagesAnnotationsMap,
PDPage page,
PDAnnotationWidget widget) |
void |
flatten()
This will flatten all form fields.
|
void |
flatten(java.util.List<PDField> fields,
boolean refreshAppearances)
This will flatten the specified form fields.
|
COSDictionary |
getCOSObject()
Convert this standard java object to a COS object.
|
java.lang.String |
getDefaultAppearance()
Get the default appearance.
|
PDResources |
getDefaultResources()
This will get the default resources for the AcroForm.
|
(package private) PDDocument |
getDocument()
This will get the document associated with this form.
|
PDField |
getField(java.lang.String fullyQualifiedName)
This will get a field by name, possibly using the cache if setCache is true.
|
java.util.Iterator<PDField> |
getFieldIterator()
Returns an iterator which walks all fields in the field tree, in order.
|
java.util.List<PDField> |
getFields()
This will return all of the documents root fields.
|
PDFieldTree |
getFieldTree()
Return the field tree representing all form fields
|
boolean |
getNeedAppearances()
True if the viewing application should construct the appearances of all field widgets.
|
int |
getQ()
This will get the document-wide default value for the quadding/justification of variable text
fields.
|
PDXFAResource |
getXFA()
Get the XFA resource, the XFA resource is only used for PDF 1.5+ forms.
|
boolean |
hasXFA()
This will tell if the AcroForm has XFA content.
|
void |
importFDF(FDFDocument fdf)
This method will import an entire FDF document into the PDF document
that this acroform is part of.
|
boolean |
isAppendOnly()
Determines if AppendOnly is set.
|
boolean |
isCachingFields()
This will tell if this acro form is caching the fields.
|
boolean |
isSignaturesExist()
Determines if SignaturesExist is set.
|
void |
refreshAppearances()
Refreshes the appearance streams and appearance dictionaries for
the widget annotations of all fields.
|
void |
refreshAppearances(java.util.List<PDField> fields)
Refreshes the appearance streams and appearance dictionaries for
the widget annotations of the specified fields.
|
private void |
removeFields(java.util.List<PDField> fields) |
private boolean |
resolveNeedsScaling(PDAnnotation annotation,
int rotation)
Check if there needs to be a scaling transformation applied.
|
private boolean |
resolveNeedsTranslation(PDAppearanceStream appearanceStream)
Check if there is a translation needed to place the annotations content.
|
void |
setAppendOnly(boolean appendOnly)
Set the AppendOnly bit.
|
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 |
setDefaultAppearance(java.lang.String daValue)
Set the default appearance.
|
void |
setDefaultResources(PDResources dr)
This will set the default resources for the acroform.
|
void |
setFields(java.util.List<PDField> fields)
Set the documents root fields.
|
void |
setNeedAppearances(java.lang.Boolean value)
Set the NeedAppearances value.
|
void |
setQ(int q)
This will set the document-wide default value for the quadding/justification of variable text
fields.
|
void |
setSignaturesExist(boolean signaturesExist)
Set the SignaturesExist bit.
|
void |
setXFA(PDXFAResource xfa)
Set the XFA resource, this is only used for PDF 1.5+ forms.
|
private void |
verifyOrCreateDefaults() |
boolean |
xfaIsDynamic()
This will tell if the AcroForm is a dynamic XFA form.
|
private static final org.apache.commons.logging.Log LOG
private static final int FLAG_SIGNATURES_EXIST
private static final int FLAG_APPEND_ONLY
private final PDDocument document
private final COSDictionary dictionary
private java.util.Map<java.lang.String,PDField> fieldCache
public PDAcroForm(PDDocument doc)
doc
- The document that this form is part of.public PDAcroForm(PDDocument doc, COSDictionary form)
doc
- The document that this form is part of.form
- The existing acroForm.private void verifyOrCreateDefaults()
PDDocument getDocument()
public COSDictionary getCOSObject()
COSObjectable
getCOSObject
in interface COSObjectable
public void importFDF(FDFDocument fdf) throws java.io.IOException
fdf
- The FDF document to import.java.io.IOException
- If there is an error doing the import.public FDFDocument exportFDF() throws java.io.IOException
java.io.IOException
- If there is an error when exporting the document.public void flatten() throws java.io.IOException
Flattening a form field will take the current appearance and make that part of the pages content stream. All form fields and annotations associated are removed.
Invisible and hidden fields will be skipped and will not become part of the page content stream
The appearances for the form fields widgets will not be generated
java.io.IOException
public void flatten(java.util.List<PDField> fields, boolean refreshAppearances) throws java.io.IOException
Flattening a form field will take the current appearance and make that part of the pages content stream. All form fields and annotations associated are removed.
Invisible and hidden fields will be skipped and will not become part of the page content stream
fields
- refreshAppearances
- if set to true the appearances for the form field widgets will be updatedjava.io.IOException
public void refreshAppearances() throws java.io.IOException
java.io.IOException
public void refreshAppearances(java.util.List<PDField> fields) throws java.io.IOException
fields
- java.io.IOException
public java.util.List<PDField> getFields()
PDNonTerminalField.getChildren()
.public void setFields(java.util.List<PDField> fields)
fields
- The fields that are part of the documents root fields.public java.util.Iterator<PDField> getFieldIterator()
public PDFieldTree getFieldTree()
public void setCacheFields(boolean cache)
cache
- A boolean telling if we should cache the fields.public boolean isCachingFields()
public PDField getField(java.lang.String fullyQualifiedName)
fullyQualifiedName
- The name of the field to get.public java.lang.String getDefaultAppearance()
public void setDefaultAppearance(java.lang.String daValue)
daValue
- a string describing the default appearancepublic boolean getNeedAppearances()
public void setNeedAppearances(java.lang.Boolean value)
value
- the value for NeedAppearancespublic PDResources getDefaultResources()
public void setDefaultResources(PDResources dr)
dr
- The new default resources.public boolean hasXFA()
public boolean xfaIsDynamic()
public PDXFAResource getXFA()
public void setXFA(PDXFAResource xfa)
xfa
- The xfa resource.public int getQ()
0 - Left(default)
1 - Centered
2 - Right
See the QUADDING constants of PDVariableText
.
public void setQ(int q)
PDVariableText
.q
- The justification of the variable text fields.public boolean isSignaturesExist()
public void setSignaturesExist(boolean signaturesExist)
signaturesExist
- The value for SignaturesExist.public boolean isAppendOnly()
public void setAppendOnly(boolean appendOnly)
appendOnly
- The value for AppendOnly.private boolean resolveNeedsTranslation(PDAppearanceStream appearanceStream)
appearanceStream
- private boolean resolveNeedsScaling(PDAnnotation annotation, int rotation)
annotation
- rotation
- private java.util.Map<COSDictionary,java.util.Set<COSDictionary>> buildPagesWidgetsMap(java.util.List<PDField> fields) throws java.io.IOException
java.io.IOException
private void fillPagesAnnotationMap(java.util.Map<COSDictionary,java.util.Set<COSDictionary>> pagesAnnotationsMap, PDPage page, PDAnnotationWidget widget)
private void removeFields(java.util.List<PDField> fields)