com.lowagie.text.pdf

Class XfaForm

public class XfaForm extends Object

Processes XFA forms.

Author: Paulo Soares (psoares@consiste.pt)

Nested Class Summary
static classXfaForm.AcroFieldsSearch
A class to process "classic" fields.
static classXfaForm.InverseStore
A structure to store each part of a SOM name and link it to the next part beginning from the lower hierarchie.
static classXfaForm.Stack2
Another stack implementation.
static classXfaForm.Xml2Som
A class for some basic SOM processing.
static classXfaForm.Xml2SomDatasets
Processes the datasets section in the XFA form.
static classXfaForm.Xml2SomTemplate
Processes the template section in the XFA form.
Field Summary
XfaForm.AcroFieldsSearchacroFieldsSom
booleanchanged
NodedatasetsNode
XfaForm.Xml2SomDatasetsdatasetsSom
DocumentdomDocument
PdfReaderreader
NodetemplateNode
XfaForm.Xml2SomTemplatetemplateSom
booleanxfaPresent
static StringXFA_DATA_SCHEMA
Constructor Summary
XfaForm()
An empty constructor to build on.
XfaForm(PdfReader reader)
A constructor from a PdfReader.
Method Summary
StringfindDatasetsName(String name)
Finds the complete SOM name contained in the datasets section from a possibly partial name.
NodefindDatasetsNode(String name)
Finds the Node contained in the datasets section from a possibly partial name.
StringfindFieldName(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.
NodegetDatasetsNode()
Gets the Node that corresponds to the datasets part.
XfaForm.Xml2SomDatasetsgetDatasetsSom()
Gets the class that contains the datasets processing section of the XFA.
DocumentgetDomDocument()
Gets the top level DOM document.
static StringgetNodeText(Node n)
Gets all the text contained in the child nodes of this node.
static StringgetNodeText(Node n, String name)
PdfReadergetReader()
Gets the PdfReader used by this instance.
XfaForm.Xml2SomTemplategetTemplateSom()
Gets the class that contains the template processing section of the XFA.
booleanisChanged()
Checks if this XFA form was changed.
booleanisXfaPresent()
Returns true if 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.
voidsetReader(PdfReader reader)
Sets the PdfReader to be used by this instance.
voidsetTemplateSom(XfaForm.Xml2SomTemplate templateSom)
Sets the class that contains the template processing section of the XFA
static voidsetXfa(byte[] xfaData, PdfReader reader, PdfWriter writer)
Sets the XFA key from a byte array.
voidsetXfa(PdfWriter writer)
Sets the XFA key from the instance data.
voidsetXfaPresent(boolean xfaPresent)
Sets the XFA form flag signaling that this is a valid XFA form.

Field Detail

acroFieldsSom

private XfaForm.AcroFieldsSearch acroFieldsSom

changed

private boolean changed

datasetsNode

private Node datasetsNode

datasetsSom

private XfaForm.Xml2SomDatasets datasetsSom

domDocument

private Document domDocument

reader

private PdfReader reader

templateNode

private Node templateNode

templateSom

private XfaForm.Xml2SomTemplate templateSom

xfaPresent

private boolean xfaPresent

XFA_DATA_SCHEMA

public static final String XFA_DATA_SCHEMA

Constructor Detail

XfaForm

public XfaForm()
An empty constructor to build on.

XfaForm

public XfaForm(PdfReader reader)
A constructor from a PdfReader. It basically does everything from finding the XFA stream to the XML parsing.

Parameters: reader the reader

Throws: java.io.IOException on error javax.xml.parsers.ParserConfigurationException on error org.xml.sax.SAXException on error

Method Detail

findDatasetsName

public String findDatasetsName(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 null if not found

findDatasetsNode

public Node findDatasetsNode(String name)
Finds the Node contained in the datasets section from a possibly partial name.

Parameters: name the complete or partial name

Returns: the Node or null if not found

findFieldName

public String findFieldName(String name, AcroFields af)
Finds the complete field name contained in the "classic" forms from a partial name.

Parameters: name the complete or partial name af the fields

Returns: the complete name or null if not found

getAcroFieldsSom

public XfaForm.AcroFieldsSearch getAcroFieldsSom()
Gets the class that contains the "classic" fields processing.

Returns: the class that contains the "classic" fields processing

getDatasetsNode

public Node getDatasetsNode()
Gets the Node that corresponds to the datasets part.

Returns: the Node that corresponds to the datasets part

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

getDomDocument

public Document getDomDocument()
Gets the top level DOM document.

Returns: the top level DOM document

getNodeText

public static String getNodeText(Node n)
Gets all the text contained in the child nodes of this node.

Parameters: n the Node

Returns: the text found or "" if no text was found

getNodeText

private static String getNodeText(Node n, String name)

getReader

public PdfReader getReader()
Gets the PdfReader used by this instance.

Returns: the PdfReader used by this 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

isChanged

public boolean isChanged()
Checks if this XFA form was changed.

Returns: true if this XFA form was changed

isXfaPresent

public boolean isXfaPresent()
Returns true if it is a XFA form.

Returns: true if it is a XFA form

serializeDoc

public static byte[] serializeDoc(Node n)
Serializes a XML document to a byte array.

Parameters: n the XML document

Returns: the serialized XML document

Throws: java.io.IOException on error

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

setChanged

public void setChanged(boolean changed)
Sets the changed status of this XFA instance.

Parameters: changed the changed status of this XFA instance

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

setDomDocument

public void setDomDocument(Document domDocument)
Sets the top DOM document.

Parameters: domDocument the top DOM document

setNodeText

public void setNodeText(Node n, 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 the Node to add the text to text the text to add

setReader

public void setReader(PdfReader reader)
Sets the PdfReader to be used by this instance.

Parameters: reader the PdfReader to be used by this instance

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

setXfa

public static void setXfa(byte[] xfaData, PdfReader reader, PdfWriter writer)
Sets the XFA key from a byte array. The old XFA is erased.

Parameters: xfaData the data reader the reader writer the writer

Throws: java.io.IOException on error

setXfa

public void setXfa(PdfWriter writer)
Sets the XFA key from the instance data. The old XFA is erased.

Parameters: writer the writer

Throws: java.io.IOException on error

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