Package com.itextpdf.text.pdf
Class XfaForm
java.lang.Object
com.itextpdf.text.pdf.XfaForm
Processes XFA forms.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA class to process "classic" fields.static classA structure to store each part of a SOM name and link it to the next part beginning from the lower hierarchy.private static classstatic classAnother stack implementation.static classA class for some basic SOM processing.static classProcesses the datasets section in the XFA form.static classProcesses the template section in the XFA form. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate XfaForm.AcroFieldsSearchprivate booleanprivate Nodeprivate XfaForm.Xml2SomDatasetsprivate Documentprivate PdfReaderprivate Nodeprivate XfaForm.Xml2SomTemplatestatic final Stringprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidSome XFA forms don't have a datasets node.private voidExtracts the nodes from the domDocument.extractXFANodes(Document domDocument) voidfillXfaForm(File file) voidfillXfaForm(File file, boolean readOnly) voidvoidfillXfaForm(InputStream is, boolean readOnly) voidfillXfaForm(Node node) voidfillXfaForm(Node node, boolean readOnly) Replaces the data under datasets/data.voidvoidfillXfaForm(InputSource is, boolean readOnly) private NodefindDataNode(Node datasetsNode) 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, AcroFields af) Finds the complete field name contained in the "classic" forms from a partial name.Gets the class that contains the "classic" fields processing.Gets theNodethat corresponds to the datasets part.Gets the class that contains the datasets processing section of the XFA.Gets the top level DOM document.private NodegetFirstElementNode(Node src) static StringgetNodeText(Node n) Gets all the text contained in the child nodes of this node.private static StringgetNodeText(Node n, String name) Gets thePdfReaderused by this instance.Gets the class that contains the template processing section of the XFA.static PdfObjectgetXfaObject(PdfReader reader) Return the XFA Object, could be an array, could be a Stream.booleanChecks if this XFA form was changed.booleanReturnstrueif it is a XFA form.static byte[]serializeDoc(Node n) Serializes a XML document to a byte array.voidsetAcroFieldsSom(XfaForm.AcroFieldsSearch acroFieldsSom) Sets the class that contains the "classic" fields processing.voidsetChanged(boolean changed) Sets the changed status of this XFA instance.voidsetDatasetsSom(XfaForm.Xml2SomDatasets datasetsSom) Sets the class that contains the datasets processing section of the XFA.voidsetDomDocument(Document domDocument) Sets the top DOM document.voidsetNodeText(Node n, String text) Sets the text of this node.voidSets thePdfReaderto be used by this instance.voidsetTemplateSom(XfaForm.Xml2SomTemplate templateSom) Sets the class that contains the template processing section of the XFAvoidSets the XFA key from the instance data.static voidSets the XFA key from a byte array.voidsetXfaPresent(boolean xfaPresent) Sets the XFA form flag signaling that this is a valid XFA form.
-
Field Details
-
templateSom
-
templateNode
-
datasetsSom
-
datasetsNode
-
acroFieldsSom
-
reader
-
xfaPresent
private boolean xfaPresent -
domDocument
-
changed
private boolean changed -
XFA_DATA_SCHEMA
- See Also:
-
-
Constructor Details
-
XfaForm
public XfaForm()An empty constructor to build on. -
XfaForm
A constructor from aPdfReader. It basically does everything from finding the XFA stream to the XML parsing.- Parameters:
reader- the reader- Throws:
IOException- on errorParserConfigurationException- on errorSAXException- on error
-
-
Method Details
-
getXfaObject
Return the XFA Object, could be an array, could be a Stream. Returns null f no XFA Object is present.- Parameters:
reader- a PdfReader instance- Returns:
- the XFA object
- Since:
- 2.1.3
-
extractNodes
private void extractNodes()Extracts the nodes from the domDocument.- Since:
- 2.1.5
-
findDataNode
-
extractXFANodes
-
createDatasetsNode
Some XFA forms don't have a datasets node. If this is the case, we have to add one. -
setXfa
Sets the XFA key from a byte array. The old XFA is erased.- Parameters:
form- the datareader- the readerwriter- the writer- Throws:
IOException- on error
-
setXfa
Sets the XFA key from the instance data. The old XFA is erased.- Parameters:
writer- the writer- Throws:
IOException- on error
-
serializeDoc
Serializes a XML document to a byte array.- Parameters:
n- the XML document- Returns:
- the serialized XML document
- Throws:
IOException- on error
-
isXfaPresent
public boolean isXfaPresent()Returnstrueif it is a XFA form.- Returns:
trueif it is a XFA form
-
getDomDocument
Gets the top level DOM document.- Returns:
- the top level DOM document
-
findFieldName
Finds the complete field name contained in the "classic" forms from a partial name.- Parameters:
name- the complete or partial nameaf- the fields- 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
-
getNodeText
-
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 totext- the text to add
-
setXfaPresent
public void setXfaPresent(boolean xfaPresent) Sets the XFA form flag signaling that this is a valid XFA form.- Parameters:
xfaPresent- the XFA form flag signaling that this is a valid XFA form
-
setDomDocument
Sets the top DOM document.- Parameters:
domDocument- the top DOM document
-
getReader
Gets thePdfReaderused by this instance.- Returns:
- the
PdfReaderused by this instance
-
setReader
Sets thePdfReaderto be used by this instance.- Parameters:
reader- thePdfReaderto be used by this instance
-
isChanged
public boolean isChanged()Checks if this XFA form was changed.- Returns:
trueif this XFA form was changed
-
setChanged
public void setChanged(boolean changed) Sets the changed status of this XFA instance.- Parameters:
changed- the changed status of this XFA instance
-
getTemplateSom
Gets the class that contains the template processing section of the XFA.- Returns:
- the class that contains the template processing section of the XFA
-
setTemplateSom
Sets the class that contains the template processing section of the XFA- Parameters:
templateSom- the class that contains the template processing section of the XFA
-
getDatasetsSom
Gets the class that contains the datasets processing section of the XFA.- Returns:
- the class that contains the datasets processing section of the XFA
-
setDatasetsSom
Sets the class that contains the datasets processing section of the XFA.- Parameters:
datasetsSom- the class that contains the datasets processing section of the XFA
-
getAcroFieldsSom
Gets the class that contains the "classic" fields processing.- Returns:
- the class that contains the "classic" fields processing
-
setAcroFieldsSom
Sets the class that contains the "classic" fields processing.- Parameters:
acroFieldsSom- the class that contains the "classic" fields processing
-
getDatasetsNode
Gets theNodethat corresponds to the datasets part.- Returns:
- the
Nodethat corresponds to the datasets part
-
fillXfaForm
- Throws:
IOException
-
fillXfaForm
- Throws:
IOException
-
fillXfaForm
- Throws:
IOException
-
fillXfaForm
- Throws:
IOException
-
fillXfaForm
- Throws:
IOException
-
fillXfaForm
- Throws:
IOException
-
fillXfaForm
-
fillXfaForm
Replaces the data under datasets/data.- Since:
- iText 5.0.0
-
getFirstElementNode
-