Package com.itextpdf.text.pdf
Class XfdfReader
- java.lang.Object
-
- com.itextpdf.text.pdf.XfdfReader
-
- All Implemented Interfaces:
SimpleXMLDocHandler
public class XfdfReader extends java.lang.Object implements SimpleXMLDocHandler
Reads a XFDF.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Stack<java.lang.String>fieldNames(package private) java.util.HashMap<java.lang.String,java.lang.String>fieldsprivate java.util.Stack<java.lang.String>fieldValues(package private) java.lang.StringfileSpecprivate booleanfoundRootprotected java.util.HashMap<java.lang.String,java.util.List<java.lang.String>>listFieldsStorage for field values if there's more than one value for a field.
-
Constructor Summary
Constructors Constructor Description XfdfReader(byte[] xfdfIn)Reads an XFDF form.XfdfReader(java.io.InputStream is)Reads an XFDF form.XfdfReader(java.lang.String filename)Reads an XFDF form.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidendDocument()Called after the document is parsed.voidendElement(java.lang.String tag)Called when an end tag is found.java.lang.StringgetField(java.lang.String name)Gets the field value.java.util.HashMap<java.lang.String,java.lang.String>getFields()Gets all the fields.java.lang.StringgetFieldValue(java.lang.String name)Gets the field value ornullif the field does not exist or has no value defined.java.lang.StringgetFileSpec()Gets the PDF file specification contained in the FDF.java.util.List<java.lang.String>getListValues(java.lang.String name)Gets the field values for a list ornullif the field does not exist or has no value defined.voidstartDocument()Called when the document starts to be parsed.voidstartElement(java.lang.String tag, java.util.Map<java.lang.String,java.lang.String> h)Called when a start tag is found.voidtext(java.lang.String str)Called when a text element is found.
-
-
-
Field Detail
-
foundRoot
private boolean foundRoot
-
fieldNames
private final java.util.Stack<java.lang.String> fieldNames
-
fieldValues
private final java.util.Stack<java.lang.String> fieldValues
-
fields
java.util.HashMap<java.lang.String,java.lang.String> fields
-
listFields
protected java.util.HashMap<java.lang.String,java.util.List<java.lang.String>> listFields
Storage for field values if there's more than one value for a field.- Since:
- 2.1.4
-
fileSpec
java.lang.String fileSpec
-
-
Constructor Detail
-
XfdfReader
public XfdfReader(java.lang.String filename) throws java.io.IOExceptionReads an XFDF form.- Parameters:
filename- the file name of the form- Throws:
java.io.IOException- on error
-
XfdfReader
public XfdfReader(byte[] xfdfIn) throws java.io.IOExceptionReads an XFDF form.- Parameters:
xfdfIn- the byte array with the form- Throws:
java.io.IOException- on error
-
XfdfReader
public XfdfReader(java.io.InputStream is) throws java.io.IOExceptionReads an XFDF form.- Parameters:
is- an InputStream to read the form- Throws:
java.io.IOException- on error- Since:
- 5.0.1
-
-
Method Detail
-
getFields
public java.util.HashMap<java.lang.String,java.lang.String> getFields()
Gets all the fields. The map is keyed by the fully qualified field name and the value is a mergedPdfDictionarywith the field content.- Returns:
- all the fields
-
getField
public java.lang.String getField(java.lang.String name)
Gets the field value.- Parameters:
name- the fully qualified field name- Returns:
- the field's value
-
getFieldValue
public java.lang.String getFieldValue(java.lang.String name)
Gets the field value ornullif the field does not exist or has no value defined.- Parameters:
name- the fully qualified field name- Returns:
- the field value or
null
-
getListValues
public java.util.List<java.lang.String> getListValues(java.lang.String name)
Gets the field values for a list ornullif the field does not exist or has no value defined.- Parameters:
name- the fully qualified field name- Returns:
- the field values or
null - Since:
- 2.1.4
-
getFileSpec
public java.lang.String getFileSpec()
Gets the PDF file specification contained in the FDF.- Returns:
- the PDF file specification contained in the FDF
-
startElement
public void startElement(java.lang.String tag, java.util.Map<java.lang.String,java.lang.String> h)Called when a start tag is found.- Specified by:
startElementin interfaceSimpleXMLDocHandler- Parameters:
tag- the tag nameh- the tag's attributes
-
endElement
public void endElement(java.lang.String tag)
Called when an end tag is found.- Specified by:
endElementin interfaceSimpleXMLDocHandler- Parameters:
tag- the tag name
-
startDocument
public void startDocument()
Called when the document starts to be parsed.- Specified by:
startDocumentin interfaceSimpleXMLDocHandler
-
endDocument
public void endDocument()
Called after the document is parsed.- Specified by:
endDocumentin interfaceSimpleXMLDocHandler
-
text
public void text(java.lang.String str)
Called when a text element is found.- Specified by:
textin interfaceSimpleXMLDocHandler- Parameters:
str- the text element, probably a fragment.
-
-