Package com.itextpdf.forms.xfa
Class XfaForm
java.lang.Object
com.itextpdf.forms.xfa.XfaForm
Processes XFA forms.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionXfaForm()An empty constructor to build on.XfaForm(PdfDictionary acroFormDictionary) A constructor from aPdfDictionary.XfaForm(PdfDocument pdfDocument) A constructor from aPdfDocument.XfaForm(InputStream inputStream) Creates an XFA form by the stream containing all xml informationCreates an XFA form by theDocumentcontaining all xml information -
Method Summary
Modifier and TypeMethodDescriptionextractXFANodes(Document domDocument) Extracts DOM nodes from an XFA document.voidfillXfaForm(File file) Replaces the XFA data under datasets/data.voidfillXfaForm(File file, boolean readOnly) Replaces the XFA data under datasets/data.voidReplaces the XFA data under datasets/data.voidfillXfaForm(InputStream is, boolean readOnly) Replaces the XFA data under datasets/data.voidfillXfaForm(Node node) Replaces the XFA data under datasets/data.voidfillXfaForm(Node node, boolean readOnly) Replaces the XFA data under datasets/data.voidReplaces the XFA data under datasets/data.voidfillXfaForm(InputSource is, boolean readOnly) Replaces the XFA data under datasets/data.findDatasetsName(String name) Finds the complete SOM name contained in the datasets section from a possibly partial name.findDatasetsNode(String name) Finds theNodecontained in the datasets section from a possibly partial name.findFieldName(String name) Finds the complete field name from a partial name.Gets theNodethat corresponds to the datasets part.Gets the top level DOM document.static StringgetNodeText(Node n) Gets all the text contained in the child nodes of this node.getNodeTextByPath(String path) Gets all the text contained in the child nodes of the node under the provided path.getXfaFieldValue(String name) Gets the xfa field value.booleanReturnstrueif it is a XFA form.voidsetDomDocument(Document domDocument) Sets the top DOM document.voidsetNodeText(Node n, String text) Sets the text of this node.voidsetXfaFieldValue(String name, String value) Changes a field value in the XFA form.static voidsetXfaForm(XfaForm form, PdfAcroForm acroForm) Sets the XFA key from a byte array.static voidsetXfaForm(XfaForm form, PdfDocument pdfDocument) Sets the XFA key from a byte array.voidwrite(PdfAcroForm acroForm) Write the XfaForm to the providedPdfAcroForm.voidwrite(PdfDocument document) Write the XfaForm to the providedPdfDocument.
-
Field Details
-
XFA_DATA_SCHEMA
The URI for the XFA Data schema.- See Also:
-
-
Constructor Details
-
XfaForm
public XfaForm()An empty constructor to build on. -
XfaForm
Creates an XFA form by the stream containing all xml information- Parameters:
-
inputStream- the InputStream
-
XfaForm
Creates an XFA form by theDocumentcontaining all xml information- Parameters:
-
domDocument- The document
-
XfaForm
A constructor from aPdfDictionary. It is assumed, but not necessary for correct initialization, that the dictionary is actually aPdfAcroForm. An entry in the dictionary with theXFAkey must contain correct XFA syntax. If theXFAkey is absent, then the constructor essentially does nothing.- Parameters:
-
acroFormDictionary- the dictionary object to initialize from
-
XfaForm
A constructor from aPdfDocument. It basically does everything from finding the XFA stream to the XML parsing.- Parameters:
-
pdfDocument- the PdfDocument instance
-
-
Method Details
-
setXfaForm
Sets the XFA key from a byte array. The old XFA is erased.- Parameters:
-
form- the data -
pdfDocument- pdfDocument - Throws:
-
IOException- if any I/O issue occurs
-
setXfaForm
Sets the XFA key from a byte array. The old XFA is erased.- Parameters:
-
form- the data -
acroForm- anPdfAcroForminstance - Throws:
-
IOException- if any I/O issue occurs
-
extractXFANodes
Extracts DOM nodes from an XFA document.- Parameters:
-
domDocument- an XFA file as aDOM document - Returns:
-
a
Mapof XFA packet names and their associatedDOM nodes
-
write
Write the XfaForm to the providedPdfDocument.- Parameters:
-
document- the PdfDocument to write the XFA Form to - Throws:
-
IOException- if any I/O issue occurs
-
write
Write the XfaForm to the providedPdfAcroForm.- Parameters:
-
acroForm- the PdfDocument to write the XFA Form to - Throws:
-
IOException- if any I/O issue occurs
-
setXfaFieldValue
Changes a field value in the XFA form.- Parameters:
-
name- the name of the field to be changed -
value- the new value
-
getXfaFieldValue
Gets the xfa field value.- Parameters:
-
name- the fully qualified field name - Returns:
- the field value
-
isXfaPresent
public boolean isXfaPresent()Returnstrueif it is a XFA form.- Returns:
-
trueif it is a XFA form
-
findFieldName
Finds the complete field name from a partial name.- Parameters:
-
name- the complete or partial name - Returns:
-
the complete name or
nullif not found
-
findDatasetsName
Finds the complete SOM name contained in the datasets section from a possibly partial name.- Parameters:
-
name- the complete or partial name - Returns:
-
the complete name or
nullif not found
-
findDatasetsNode
Finds theNodecontained in the datasets section from a possibly partial name.- Parameters:
-
name- the complete or partial name - Returns:
-
the
Nodeornullif not found
-
getNodeText
Gets all the text contained in the child nodes of this node.- Parameters:
-
n- theNode - Returns:
- the text found or "" if no text was found
-
getNodeTextByPath
Gets all the text contained in the child nodes of the node under the provided path.- Parameters:
-
path- path to the node to extract text in the format "some.path.to.node" - Returns:
-
text found under the provided path or
nullif node or text wasn't found
-
setNodeText
Sets the text of this node. All the child's node are deleted and a new child text node is created.- Parameters:
-
n- theNodeto add the text to -
text- the text to add
-
getDomDocument
Gets the top level DOM document.- Returns:
- the top level DOM document
-
setDomDocument
Sets the top DOM document.- Parameters:
-
domDocument- the top DOM document
-
getDatasetsNode
Gets theNodethat corresponds to the datasets part.- Returns:
-
the
Nodethat corresponds to the datasets part
-
fillXfaForm
Replaces the XFA data under datasets/data. Accepts afile objectto fill this object with XFA data. The resulting DOM document may be modified.- Parameters:
-
file- theFile - Throws:
-
IOException- if any I/O issue occurs on theInputSource
-
fillXfaForm
Replaces the XFA data under datasets/data. Accepts afile objectto fill this object with XFA data.- Parameters:
-
file- theFile -
readOnly- whether or not the resulting DOM document may be modified - Throws:
-
IOException- if any I/O issue occurs on theInputSource
-
fillXfaForm
Replaces the XFA data under datasets/data. Accepts anInputStreamto fill this object with XFA data. The resulting DOM document may be modified.- Parameters:
-
is- theInputStream - Throws:
-
IOException- if any I/O issue occurs on theInputSource
-
fillXfaForm
Replaces the XFA data under datasets/data. Accepts anInputStreamto fill this object with XFA data.- Parameters:
-
is- theInputStream -
readOnly- whether or not the resulting DOM document may be modified - Throws:
-
IOException- if any I/O issue occurs on theInputSource
-
fillXfaForm
Replaces the XFA data under datasets/data. Accepts aSAX input sourceto fill this object with XFA data. The resulting DOM document may be modified.- Parameters:
-
is- theSAX input source - Throws:
-
IOException- if any I/O issue occurs on theInputSource
-
fillXfaForm
Replaces the XFA data under datasets/data. Accepts aSAX input sourceto fill this object with XFA data.- Parameters:
-
is- theSAX input source -
readOnly- whether or not the resulting DOM document may be modified - Throws:
-
IOException- if any I/O issue occurs on theInputSource
-
fillXfaForm
Replaces the XFA data under datasets/data.- Parameters:
-
node- the inputNode
-
fillXfaForm
Replaces the XFA data under datasets/data.- Parameters:
-
node- the inputNode -
readOnly- whether or not the resulting DOM document may be modified
-