- java.lang.Object
-
- com.itextpdf.text.pdf.XfaForm
-
public class XfaForm extends java.lang.ObjectProcesses XFA forms.- Author:
- Paulo Soares (psoares@consiste.pt)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classXfaForm.AcroFieldsSearchA class to process "classic" fields.static classXfaForm.InverseStoreA structure to store each part of a SOM name and link it to the next part beginning from the lower hierarchy.static classXfaForm.Stack2Another stack implementation.static classXfaForm.Xml2SomA class for some basic SOM processing.static classXfaForm.Xml2SomDatasetsProcesses the datasets section in the XFA form.static classXfaForm.Xml2SomTemplateProcesses the template section in the XFA form.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringXFA_DATA_SCHEMA
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfillXfaForm(java.io.File file)voidfillXfaForm(java.io.InputStream is)voidfillXfaForm(org.w3c.dom.Node node)Replaces the data under datasets/data.voidfillXfaForm(org.xml.sax.InputSource is)java.lang.StringfindDatasetsName(java.lang.String name)Finds the complete SOM name contained in the datasets section from a possibly partial name.org.w3c.dom.NodefindDatasetsNode(java.lang.String name)Finds theNodecontained in the datasets section from a possibly partial name.java.lang.StringfindFieldName(java.lang.String name, AcroFields af)Finds the complete field name contained in the "classic" forms from a partial name.XfaForm.AcroFieldsSearchgetAcroFieldsSom()Gets the class that contains the "classic" fields processing.org.w3c.dom.NodegetDatasetsNode()Gets theNodethat corresponds to the datasets part.XfaForm.Xml2SomDatasetsgetDatasetsSom()Gets the class that contains the datasets processing section of the XFA.org.w3c.dom.DocumentgetDomDocument()Gets the top level DOM document.static java.lang.StringgetNodeText(org.w3c.dom.Node n)Gets all the text contained in the child nodes of this node.PdfReadergetReader()Gets thePdfReaderused by this instance.XfaForm.Xml2SomTemplategetTemplateSom()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.booleanisChanged()Checks if this XFA form was changed.booleanisXfaPresent()Returnstrueif it is a XFA form.static byte[]serializeDoc(org.w3c.dom.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(org.w3c.dom.Document domDocument)Sets the top DOM document.voidsetNodeText(org.w3c.dom.Node n, java.lang.String text)Sets the text of this node.voidsetReader(PdfReader reader)Sets thePdfReaderto be used by this instance.voidsetTemplateSom(XfaForm.Xml2SomTemplate templateSom)Sets the class that contains the template processing section of the XFAvoidsetXfa(PdfWriter writer)Sets the XFA key from the instance data.static voidsetXfa(XfaForm form, PdfReader reader, PdfWriter writer)Sets the XFA key from a byte array.voidsetXfaPresent(boolean xfaPresent)Sets the XFA form flag signaling that this is a valid XFA form.
-
-
-
Field Detail
-
XFA_DATA_SCHEMA
public static final java.lang.String XFA_DATA_SCHEMA
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XfaForm
public XfaForm()
An empty constructor to build on.
-
XfaForm
public XfaForm(PdfReader reader) throws java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
A constructor from aPdfReader. It basically does everything from finding the XFA stream to the XML parsing.- Parameters:
reader- the reader- Throws:
java.io.IOException- on errorjavax.xml.parsers.ParserConfigurationException- on errororg.xml.sax.SAXException- on error
-
-
Method Detail
-
getXfaObject
public static PdfObject getXfaObject(PdfReader reader)
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
-
setXfa
public static void setXfa(XfaForm form, PdfReader reader, PdfWriter writer) throws java.io.IOException
Sets the XFA key from a byte array. The old XFA is erased.- Parameters:
form- the datareader- the readerwriter- the writer- Throws:
java.io.IOException- on error
-
setXfa
public void setXfa(PdfWriter writer) throws java.io.IOException
Sets the XFA key from the instance data. The old XFA is erased.- Parameters:
writer- the writer- Throws:
java.io.IOException- on error
-
serializeDoc
public static byte[] serializeDoc(org.w3c.dom.Node n) throws java.io.IOExceptionSerializes a XML document to a byte array.- Parameters:
n- the XML document- Returns:
- the serialized XML document
- Throws:
java.io.IOException- on error
-
isXfaPresent
public boolean isXfaPresent()
Returnstrueif it is a XFA form.- Returns:
trueif it is a XFA form
-
getDomDocument
public org.w3c.dom.Document getDomDocument()
Gets the top level DOM document.- Returns:
- the top level DOM document
-
findFieldName
public java.lang.String findFieldName(java.lang.String name, AcroFields af)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
public java.lang.String findDatasetsName(java.lang.String name)
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
public org.w3c.dom.Node findDatasetsNode(java.lang.String name)
Finds theNodecontained in the datasets section from a possibly partial name.- Parameters:
name- the complete or partial name- Returns:
- the
Nodeornullif not found
-
getNodeText
public static java.lang.String getNodeText(org.w3c.dom.Node n)
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
-
setNodeText
public void setNodeText(org.w3c.dom.Node n, java.lang.String text)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
public void setDomDocument(org.w3c.dom.Document domDocument)
Sets the top DOM document.- Parameters:
domDocument- the top DOM document
-
getReader
public PdfReader getReader()
Gets thePdfReaderused by this instance.- Returns:
- the
PdfReaderused by this instance
-
setReader
public void setReader(PdfReader reader)
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
public XfaForm.Xml2SomTemplate 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
public void setTemplateSom(XfaForm.Xml2SomTemplate templateSom)
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
public XfaForm.Xml2SomDatasets 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
public void setDatasetsSom(XfaForm.Xml2SomDatasets datasetsSom)
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
public XfaForm.AcroFieldsSearch getAcroFieldsSom()
Gets the class that contains the "classic" fields processing.- Returns:
- the class that contains the "classic" fields processing
-
setAcroFieldsSom
public void setAcroFieldsSom(XfaForm.AcroFieldsSearch acroFieldsSom)
Sets the class that contains the "classic" fields processing.- Parameters:
acroFieldsSom- the class that contains the "classic" fields processing
-
getDatasetsNode
public org.w3c.dom.Node getDatasetsNode()
Gets theNodethat corresponds to the datasets part.- Returns:
- the
Nodethat corresponds to the datasets part
-
fillXfaForm
public void fillXfaForm(java.io.File file) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException- Throws:
javax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXExceptionjava.io.IOException
-
fillXfaForm
public void fillXfaForm(java.io.InputStream is) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException- Throws:
javax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXExceptionjava.io.IOException
-
fillXfaForm
public void fillXfaForm(org.xml.sax.InputSource is) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException- Throws:
javax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXExceptionjava.io.IOException
-
fillXfaForm
public void fillXfaForm(org.w3c.dom.Node node)
Replaces the data under datasets/data.- Since:
- iText 5.0.0
-
-