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
-
-
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
-
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 datapdfDocument- 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 dataacroForm- anPdfAcroForminstance- Throws:
IOException- if any I/O issue occurs
-
extractXFANodes
-
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
-
getXfaFieldValue
-
isXfaPresent
public boolean isXfaPresent()Returnstrueif it is a XFA form.- Returns:
trueif it is a XFA form
-
findFieldName
-
findDatasetsName
-
findDatasetsNode
-
getNodeText
-
getNodeTextByPath
-
setNodeText
-
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- theFilereadOnly- 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- theInputStreamreadOnly- 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 sourcereadOnly- whether or not the resulting DOM document may be modified- Throws:
IOException- if any I/O issue occurs on theInputSource
-
fillXfaForm
-
fillXfaForm
-