public class XfaForm
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
XfaForm.AcroFieldsSearch
A class to process "classic" fields.
|
static class |
XfaForm.InverseStore
A structure to store each part of a SOM name and link it to the next part
beginning from the lower hierarchy.
|
static class |
XfaForm.Stack2
Another stack implementation.
|
static class |
XfaForm.Xml2Som
A class for some basic SOM processing.
|
static class |
XfaForm.Xml2SomDatasets
Processes the datasets section in the XFA form.
|
static class |
XfaForm.Xml2SomTemplate
Processes the template section in the XFA form.
|
Modifier and Type | Field and Description |
---|---|
private XfaForm.AcroFieldsSearch |
acroFieldsSom |
private boolean |
changed |
private org.w3c.dom.Node |
datasetsNode |
private XfaForm.Xml2SomDatasets |
datasetsSom |
private org.w3c.dom.Document |
domDocument |
private PdfReader |
reader |
private org.w3c.dom.Node |
templateNode |
private XfaForm.Xml2SomTemplate |
templateSom |
static java.lang.String |
XFA_DATA_SCHEMA |
private boolean |
xfaPresent |
Constructor and Description |
---|
XfaForm()
An empty constructor to build on.
|
XfaForm(PdfReader reader)
A constructor from a
PdfReader . |
Modifier and Type | Method and Description |
---|---|
private void |
extractNodes()
Extracts the nodes from the domDocument.
|
void |
fillXfaForm(java.io.File file) |
void |
fillXfaForm(org.xml.sax.InputSource is) |
void |
fillXfaForm(java.io.InputStream is) |
void |
fillXfaForm(org.w3c.dom.Node node)
Replaces the data under datasets/data.
|
java.lang.String |
findDatasetsName(java.lang.String name)
Finds the complete SOM name contained in the datasets section from a
possibly partial name.
|
org.w3c.dom.Node |
findDatasetsNode(java.lang.String name)
Finds the
Node contained in the datasets section from a
possibly partial name. |
java.lang.String |
findFieldName(java.lang.String name,
AcroFields af)
Finds the complete field name contained in the "classic" forms from a partial
name.
|
XfaForm.AcroFieldsSearch |
getAcroFieldsSom()
Gets the class that contains the "classic" fields processing.
|
org.w3c.dom.Node |
getDatasetsNode()
Gets the
Node that corresponds to the datasets part. |
XfaForm.Xml2SomDatasets |
getDatasetsSom()
Gets the class that contains the datasets processing section of the XFA.
|
org.w3c.dom.Document |
getDomDocument()
Gets the top level DOM document.
|
static java.lang.String |
getNodeText(org.w3c.dom.Node n)
Gets all the text contained in the child nodes of this node.
|
private static java.lang.String |
getNodeText(org.w3c.dom.Node n,
java.lang.String name) |
PdfReader |
getReader()
Gets the
PdfReader used by this instance. |
XfaForm.Xml2SomTemplate |
getTemplateSom()
Gets the class that contains the template processing section of the XFA.
|
static PdfObject |
getXfaObject(PdfReader reader)
Return the XFA Object, could be an array, could be a Stream.
|
boolean |
isChanged()
Checks if this XFA form was changed.
|
boolean |
isXfaPresent()
Returns
true if it is a XFA form. |
static byte[] |
serializeDoc(org.w3c.dom.Node n)
Serializes a XML document to a byte array.
|
void |
setAcroFieldsSom(XfaForm.AcroFieldsSearch acroFieldsSom)
Sets the class that contains the "classic" fields processing.
|
void |
setChanged(boolean changed)
Sets the changed status of this XFA instance.
|
void |
setDatasetsSom(XfaForm.Xml2SomDatasets datasetsSom)
Sets the class that contains the datasets processing section of the XFA.
|
void |
setDomDocument(org.w3c.dom.Document domDocument)
Sets the top DOM document.
|
void |
setNodeText(org.w3c.dom.Node n,
java.lang.String text)
Sets the text of this node.
|
void |
setReader(PdfReader reader)
Sets the
PdfReader to be used by this instance. |
void |
setTemplateSom(XfaForm.Xml2SomTemplate templateSom)
Sets the class that contains the template processing section of the XFA
|
void |
setXfa(PdfWriter writer)
Sets the XFA key from the instance data.
|
static void |
setXfa(XfaForm form,
PdfReader reader,
PdfWriter writer)
Sets the XFA key from a byte array.
|
void |
setXfaPresent(boolean xfaPresent)
Sets the XFA form flag signaling that this is a valid XFA form.
|
private XfaForm.Xml2SomTemplate templateSom
private org.w3c.dom.Node templateNode
private XfaForm.Xml2SomDatasets datasetsSom
private org.w3c.dom.Node datasetsNode
private XfaForm.AcroFieldsSearch acroFieldsSom
private PdfReader reader
private boolean xfaPresent
private org.w3c.dom.Document domDocument
private boolean changed
public static final java.lang.String XFA_DATA_SCHEMA
public XfaForm()
public XfaForm(PdfReader reader) throws java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
PdfReader
. It basically does everything
from finding the XFA stream to the XML parsing.reader
- the readerjava.io.IOException
- on errorjavax.xml.parsers.ParserConfigurationException
- on errororg.xml.sax.SAXException
- on errorpublic static PdfObject getXfaObject(PdfReader reader)
reader
- a PdfReader instanceprivate void extractNodes()
public static void setXfa(XfaForm form, PdfReader reader, PdfWriter writer) throws java.io.IOException
form
- the datareader
- the readerwriter
- the writerjava.io.IOException
- on errorpublic void setXfa(PdfWriter writer) throws java.io.IOException
writer
- the writerjava.io.IOException
- on errorpublic static byte[] serializeDoc(org.w3c.dom.Node n) throws java.io.IOException
n
- the XML documentjava.io.IOException
- on errorpublic boolean isXfaPresent()
true
if it is a XFA form.true
if it is a XFA formpublic org.w3c.dom.Document getDomDocument()
public java.lang.String findFieldName(java.lang.String name, AcroFields af)
name
- the complete or partial nameaf
- the fieldsnull
if not foundpublic java.lang.String findDatasetsName(java.lang.String name)
name
- the complete or partial namenull
if not foundpublic org.w3c.dom.Node findDatasetsNode(java.lang.String name)
Node
contained in the datasets section from a
possibly partial name.name
- the complete or partial nameNode
or null
if not foundpublic static java.lang.String getNodeText(org.w3c.dom.Node n)
n
- the Node
private static java.lang.String getNodeText(org.w3c.dom.Node n, java.lang.String name)
public void setNodeText(org.w3c.dom.Node n, java.lang.String text)
n
- the Node
to add the text totext
- the text to addpublic void setXfaPresent(boolean xfaPresent)
xfaPresent
- the XFA form flag signaling that this is a valid XFA formpublic void setDomDocument(org.w3c.dom.Document domDocument)
domDocument
- the top DOM documentpublic PdfReader getReader()
PdfReader
used by this instance.PdfReader
used by this instancepublic void setReader(PdfReader reader)
PdfReader
to be used by this instance.reader
- the PdfReader
to be used by this instancepublic boolean isChanged()
true
if this XFA form was changedpublic void setChanged(boolean changed)
changed
- the changed status of this XFA instancepublic XfaForm.Xml2SomTemplate getTemplateSom()
public void setTemplateSom(XfaForm.Xml2SomTemplate templateSom)
templateSom
- the class that contains the template processing section of the XFApublic XfaForm.Xml2SomDatasets getDatasetsSom()
public void setDatasetsSom(XfaForm.Xml2SomDatasets datasetsSom)
datasetsSom
- the class that contains the datasets processing section of the XFApublic XfaForm.AcroFieldsSearch getAcroFieldsSom()
public void setAcroFieldsSom(XfaForm.AcroFieldsSearch acroFieldsSom)
acroFieldsSom
- the class that contains the "classic" fields processingpublic org.w3c.dom.Node getDatasetsNode()
Node
that corresponds to the datasets part.Node
that corresponds to the datasets partpublic void fillXfaForm(java.io.File file) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public void fillXfaForm(java.io.InputStream is) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public void fillXfaForm(org.xml.sax.InputSource is) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public void fillXfaForm(org.w3c.dom.Node node)