- All Implemented Interfaces:
COSObjectable
- Author:
- Ben Litchfield
-
Constructor Summary
ConstructorsConstructorDescriptionPDAcroForm(PDDocument document) PDAcroForm(PDDocument document, COSDictionary form) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFields(Collection<PDField> toAdd) Adds the fields to the root fields of the formvoidflatten()This will flatten all form fields.voidThis will flatten the specified form fields.This will get the default resources for the acro form.This will get the document associated with this form.This will get a field by name, possibly using the cache if setCache is true.Returns an iterator which walks all fields in the field tree, post-order.This will return all of the documents root fields.intThis will get the 'quadding' or justification of the text to be displayed.Set a handler to support JavaScript actions in the form.getXFA()Get the XFA resource, the XFA resource is only used for PDF 1.5+ forms.booleanhasXFA()This will tell if the AcroForm has XFA content.booleanDetermines if AppendOnly is set.booleanTrue if the viewing application should construct the appearances of all field widgets.booleanDetermines if SignaturesExist is set.voidRefreshes the appearance streams and appearance dictionaries for the widget annotations of all fields.voidrefreshAppearances(List<PDField> fields) Refreshes the appearance streams and appearance dictionaries for the widget annotations of the specified fields.removeField(PDField remove) removes the given field from the root fields of the formvoidsetAppendOnly(boolean appendOnly) Set the AppendOnly bit.voidvoidsetDefaultAppearance(String daValue) Set the default appearance.voidThis will set the default resources for the acroform.voidSet the documents root fields.voidsetNeedAppearances(Boolean value) Set the NeedAppearances value.voidsetQuadding(int q) This will set the quadding/justification of the text.voidsetScriptingHandler(ScriptingHandler scriptingHandler) Set a handler to support JavaScript actions in the form.voidsetSignaturesExist(boolean signaturesExist) Set the SignaturesExist bit.voidsetXFA(PDXFAResource xfa) Set the XFA resource, this is only used for PDF 1.5+ forms.booleanThis will tell if the AcroForm is a dynamic XFA form.Methods inherited from class org.sejda.sambox.pdmodel.common.PDDictionaryWrapper
equals, getCOSObject, hashCode
-
Constructor Details
-
PDAcroForm
- Parameters:
document- The document that this form is part of.
-
PDAcroForm
- Parameters:
document- 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.
-
flatten
This will flatten all form fields.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.
The appearances for the form fields widgets will not be generated
- Throws:
IOException
-
flatten
This will flatten the specified form fields.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.
- Parameters:
refreshAppearances- if set to true the appearances for the form field widgets will be updated- Throws:
IOException
-
refreshAppearances
Refreshes the appearance streams and appearance dictionaries for the widget annotations of all fields.- Throws:
IOException
-
refreshAppearances
Refreshes the appearance streams and appearance dictionaries for the widget annotations of the specified fields.- Throws:
IOException
-
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 using
PDNonTerminalField.getChildren().- Returns:
- A list of the documents root fields, never null. If there are no fields then this method returns an empty list.
-
addFields
Adds the fields to the root fields of the form- Parameters:
toAdd-
-
removeField
removes the given field from the root fields of the form- Returns:
- the removed element or null
-
setFields
Set the documents root fields.- Parameters:
fields- The fields that are part of the documents root fields.
-
getFieldIterator
Returns an iterator which walks all fields in the field tree, post-order. -
getFieldTree
- Returns:
- the field tree representing all form fields and allowing a post-order visit of the tree
-
getField
This will get a field by name, possibly using the cache if setCache is true.- Parameters:
fullyQualifiedName- The name of the field to get.- Returns:
- The field with that name of null if one was not found.
-
getDefaultAppearance
- Returns:
- the DA element of the dictionary object or null if nothing is defined
-
setDefaultAppearance
Set the default appearance.- Parameters:
daValue- a string describing the default appearance
-
getCalculationOrder
-
setCalculationOrder
-
isNeedAppearances
public boolean isNeedAppearances()True if the viewing application should construct the appearances of all field widgets. The default value is false.- Returns:
- the value of NeedAppearances, false if the value isn't set
-
setNeedAppearances
Set the NeedAppearances value. If this is false, PDFBox will create appearances for all field widget.- Parameters:
value- the value for NeedAppearances
-
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.
-
hasXFA
public boolean hasXFA()This will tell if the AcroForm has XFA content.- Returns:
- true if the AcroForm is an XFA form
-
xfaIsDynamic
public boolean xfaIsDynamic()This will tell if the AcroForm is a dynamic XFA form.- Returns:
- true if the AcroForm is a dynamic XFA form
-
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.
-
getQuadding
public int getQuadding()This will get the 'quadding' or justification of the text to be displayed. 0 - Left(default)
1 - Centered
2 - Right
See the QUADDING constants ofPDVariableText.- Returns:
- The justification of the text strings.
-
setQuadding
public void setQuadding(int q) This will set the quadding/justification of the text. See QUADDING constants.- Parameters:
q- The new text justification.
-
isSignaturesExist
public boolean isSignaturesExist()Determines if SignaturesExist is set.- Returns:
- true if the document contains at least one signature.
-
setSignaturesExist
public void setSignaturesExist(boolean signaturesExist) Set the SignaturesExist bit.- Parameters:
signaturesExist- The value for SignaturesExist.
-
isAppendOnly
public boolean isAppendOnly()Determines if AppendOnly is set.- Returns:
- true if the document contains signatures that may be invalidated if the file is saved.
-
setAppendOnly
public void setAppendOnly(boolean appendOnly) Set the AppendOnly bit.- Parameters:
appendOnly- The value for AppendOnly.
-
getScriptingHandler
Set a handler to support JavaScript actions in the form.- Returns:
- scriptingHandler
-
setScriptingHandler
Set a handler to support JavaScript actions in the form.- Parameters:
scriptingHandler-
-