Summary: Ctors | Methods | Inherited Methods | [Expand All]
public class

# FDFDoc

extends Object
implements AutoCloseable

java.lang.Object
↳ | com.pdftron.fdf.FDFDoc

## Class Overview

FDFDoc is a class representing Forms Data Format (FDF) documents. FDF is typically used when submitting form data to a server, receiving the response, and incorporating it into the interactive form. It can also be used to export form data to stand-alone files that can be stored, transmitted electronically, and imported back into the corresponding PDF interactive form. In addition, beginning in PDF 1.3, FDF can be used to define a container for annotations that are separate from the PDF document to which they apply. Note: While the constructor does not, a few methods in FDFDoc will cause it to count as a document for the consumption-based licensing if was not created through PDFDoc::FDFExtract(). Please consult individual API documentation for exact details.

## Summary

Public Constructors
| FDFDoc() Default constructor.
| FDFDoc(SDFDoc sdfdoc) Create a FDF document from an existing SDF/Cos document.
| FDFDoc(String filepath) Open an existing FDF document.
| FDFDoc(Filter stream) Open an existing FDF document.
| FDFDoc(byte[] buf) Open a SDF/Cos document from a memory buffer.
| FDFDoc(InputStream stream) Open an existing FDF document from an InputStream.
| FDFDoc(InputStream stream, int size) Open an existing FDF document from an InputStream.

Public Methods
static FDFDoc | __Create(long impl)
long | __GetHandle()
void | close() Close FDFDoc
static FDFDoc | createFromXFDF(String xfdf) Create a new FDFDoc from XFDF input.
FDFField | fieldCreate(String field_name, int field_type) Create a new interactive form FDFField.
FDFField | fieldCreate(String field_name, int field_type, String field_value) Create a FDFField with specified name, type and string value
FDFField | fieldCreate(String field_name, int field_type, Obj field_value) Create a FDFField with specified name, type and value
Obj | getFDF() Get the FDF dictionary.
FDFField | getField(String field_name) field_name a string representing the fully qualified name of the field (e.g.
FDFFieldIterator | getFieldIterator(String field_name) Get the field iterator.
FDFFieldIterator | getFieldIterator() An interactive form (sometimes referred to as an AcroForm) is a collection of fields for gathering information interactively from the user.
Obj | getID() Get the ID entry from "/Root/FDF" dictionary.
String | getPDFFileName() Get the PDF document file that this FDF file was exported from or is intended to be imported into.
Obj | getRoot() Get the root.
SDFDoc | getSDFDoc() Get the SDFDoc object in FDFDoc
Obj | getTrailer() Get the trailer.
boolean | isModified() determine whether the document is modified
void | mergeAnnots(String command_file) Merges XFDF annotations into FDF document.
void | mergeAnnots(String command_file, String permitted_user) Merges XFDF annotations into FDF document.
void | save(OutputStream stream) Saves the document to a an OutputStream.
void | save(OutputStream stream, int size) Saves the document to a an OutputStream.
void | save(String path) Saves the document to a file.
byte[] | save() Saves the document to a memory buffer.
void | saveAsXFDF(String path) Save a FDF document in XFDF format.
String | saveAsXFDF() Save a FDF document in XFDF format and returns the XFDF string
String | saveAsXFDF(XFDFExportOptions opts) Save a FDF document in XFDF format and returns the XFDF string
void | saveAsXFDF(String path, XFDFExportOptions opts) Save a FDF document in XFDF format.
void | setID(Obj id) Set the ID entry in "/Root/FDF" dictionary.
void | setPDFFileName(String filepath) Set the PDF document file that this FDF file was exported from or is intended to be imported into.

[Expand] Inherited Methods
From class java.lang.Object
boolean | equals(Object arg0)
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()
From interface java.lang.AutoCloseable
abstract void | close()

## Public Constructors

#### public FDFDoc ()

Default constructor. Creates an empty FDF document.

##### Throws

PDFNetException |

#### public FDFDoc (SDFDoc sdfdoc)

Create a FDF document from an existing SDF/Cos document.

##### Parameters

sdfdoc | An SDF document. Created FDFDoc will take the ownership of the low-level document.

##### Throws

PDFNetException |

#### public FDFDoc (String filepath)

Open an existing FDF document.

##### Parameters

filepath | pathname to the file.

##### Throws

PDFNetException |

#### public FDFDoc (Filter stream)

Open an existing FDF document.

Note: if the input stream doesn't support Seek() operation the document will load whole data stream in memory before parsing. In case of linearized FDF, the document may be parsed on-the-fly while it is being loaded in memory. Note that since StdFile implements Seek() interface, the document does not have to be fully in memory before it is used. Make sure to call InitSecurityHandler() after FDFDoc(...) for encrypted documents.

##### Parameters

stream | input stream containing a serialized document. The input stream may be a random-access file, memory buffer, slow HTTP connection etc.

##### Throws

PDFNetException |

#### public FDFDoc (byte[] buf)

Open a SDF/Cos document from a memory buffer.

Note: the document should be fully loaded in the memory buffer.

##### Parameters

buf | a memory buffer containing the serialized document

##### Throws

PDFNetException |

#### public FDFDoc (InputStream stream)

Open an existing FDF document from an InputStream.

Note: Make sure to call InitSecurityHandler() after FDFDoc(...) for encrypted documents.

##### Parameters

stream | - input stream containing a serialized document.

##### Throws

PDFNetException |
IOException | Signals that an I/O exception has occurred.

#### public FDFDoc (InputStream stream, int size)

Open an existing FDF document from an InputStream.

Note: Make sure to call InitSecurityHandler() after FDFDoc(...) for encrypted documents.

##### Parameters

stream | - input stream containing a serialized document.
size | - the expected size of the input stream.

##### Throws

PDFNetException |
IOException | Signals that an I/O exception has occurred.

## Public Methods

#### public static FDFDoc __Create (long impl)

#### public long __GetHandle ()

#### public void close ()

Close FDFDoc

##### Throws

PDFNetException |

#### public static FDFDoc createFromXFDF (String xfdf)

Create a new FDFDoc from XFDF input. Input can be either a XFDF file path, or the XFDF data itself.

##### Parameters

xfdf | the string containing either the file path to a XFDF file, or the XML buffer containing the XFDF.

##### Returns

- created FDFDoc

##### Throws

PDFNetException |

#### public FDFField fieldCreate (String field_name, int field_type)

Create a new interactive form FDFField.

##### Parameters

field_name | the field_name
field_type | the field_type

##### Returns

- the fDF field

##### Throws

PDFNetException |

#### public FDFField fieldCreate (String field_name, int field_type, String field_value)

Create a FDFField with specified name, type and string value

##### Parameters

field_name | the field_name
field_type | the field_type
field_value | the field_value

##### Returns

- the fDF field

##### Throws

PDFNetException |

#### public FDFField fieldCreate (String field_name, int field_type, Obj field_value)

Create a FDFField with specified name, type and value

##### Parameters

field_name | the field_name
field_type | the field_type
field_value | the field_value

##### Returns

- the fDF field

##### Throws

PDFNetException |

#### public Obj getFDF ()

Get the FDF dictionary.

##### Returns

- the FDF dictionary located in "/Root" or NULL if dictionary is not present.

##### Throws

PDFNetException |

#### public FDFField getField (String field_name)

field_name a string representing the fully qualified name of the field (e.g. "employee.name.first").

##### Parameters

field_name | the field_name

##### Returns

- a FDFFieldIterator referring to the given interactive FDFField or if the field name was not found HasNext() will return false.

##### Throws

PDFNetException |

#### public FDFFieldIterator getFieldIterator (String field_name)

Get the field iterator.

##### Parameters

field_name | the field_name

##### Returns

- the field iterator

##### Throws

PDFNetException |

#### public FDFFieldIterator getFieldIterator ()

An interactive form (sometimes referred to as an AcroForm) is a collection of fields for gathering information interactively from the user. A FDF document may contain any number of fields appearing on any combination of pages, all of which make up a single, global interactive form spanning the entire document. The following methods are used to access and manipulate Interactive form fields (sometimes referred to as AcroForms).

Note: if the document has no AcroForms, HasNext() will return false.

##### Returns

- an iterator to the first Filed in the document.

##### Throws

PDFNetException |

#### public Obj getID ()

Get the ID entry from "/Root/FDF" dictionary.

##### Returns

- An object representing the ID entry in "/Root/FDF" dictionary.

##### Throws

PDFNetException |

#### public String getPDFFileName ()

Get the PDF document file that this FDF file was exported from or is intended to be imported into.

##### Returns

- a String with the PDF document file name.

##### Throws

PDFNetException |

#### public Obj getRoot ()

Get the root. Note: This method will count as a document usage for consumption-based licensing if the current document has not yet been counted.

##### Returns

- A dictionary representing the Cos root of the document (/Root entry within the trailer dictionary)

##### Throws

PDFNetException |

#### public SDFDoc getSDFDoc ()

Get the SDFDoc object in FDFDoc

##### Returns

- document's SDF/Cos document Note: This method will count as a document usage for consumption-based licensing if the current document has not yet been counted.

#### public Obj getTrailer ()

Get the trailer. Note: This method will count as a document usage for consumption-based licensing if the current document has not yet been counted.

##### Returns

- A dictionary representing the Cos root of the document (document's trailer)

##### Throws

PDFNetException |

#### public boolean isModified ()

determine whether the document is modified

##### Returns

- true if document was modified, false otherwise

##### Throws

PDFNetException |

#### public void mergeAnnots (String command_file)

Merges XFDF annotations into FDF document.

##### Parameters

command_file | the path to the xml command file, or the xml command itself

##### Throws

PDFNetException |

#### public void mergeAnnots (String command_file, String permitted_user)

Merges XFDF annotations into FDF document.

##### Parameters

command_file | the path to the xml command file, or the xml command itself
permitted_user | the user name of the permitted user

##### Throws

PDFNetException |

#### public void save (OutputStream stream)

Saves the document to a an OutputStream. Note: This method will count as a document usage for consumption-based licensing if the current document has not yet been counted.

##### Parameters

stream | An OutputStream where the document should be serialized.

##### Throws

PDFNetException |
IOException | Signals that an I/O exception has occurred.

#### public void save (OutputStream stream, int size)

Saves the document to a an OutputStream. Note: This method will count as a document usage for consumption-based licensing if the current document has not yet been counted.

##### Parameters

stream | An OutputStream where the document should be serialized.
size | The expected size of the output stream.

##### Throws

PDFNetException |
IOException | Signals that an I/O exception has occurred.

#### public void save (String path)

Saves the document to a file. If a full save is requested to the original path, the file is saved to a file system-determined temporary file, the old file is deleted, and the temporary file is renamed to path. A full save with remove unused or linearization option may re-arrange object in the cross reference table. Therefore all pointers and references to document objects and resources should be re acquired in order to continue document editing. In order to use incremental save the specified path must match original path and e_incremental flag bit should be set. Note: This method will count as a document usage for consumption-based licensing if the current document has not yet been counted.

##### Parameters

path | The full path name to which the file is saved.

##### Throws

PDFNetException |

#### public byte[] save ()

Saves the document to a memory buffer. Note: This method will count as a document usage for consumption-based licensing if the current document has not yet been counted.

##### Returns

- the buffer containing the serialized version of the document.

##### Throws

PDFNetException |

#### public void saveAsXFDF (String path)

Save a FDF document in XFDF format.

##### Parameters

path | the path

##### Throws

PDFNetException |

#### public String saveAsXFDF ()

Save a FDF document in XFDF format and returns the XFDF string

##### Returns

- XFDF string representation of the FDF document

##### Throws

PDFNetException |

#### public String saveAsXFDF (XFDFExportOptions opts)

Save a FDF document in XFDF format and returns the XFDF string

##### Returns

- XFDF string representation of the FDF document

##### Throws

PDFNetException |

#### public void saveAsXFDF (String path, XFDFExportOptions opts)

Save a FDF document in XFDF format.

##### Parameters

path | the path
opts | Options controlling finer parameters of xfdf export

##### Throws

PDFNetException |

#### public void setID (Obj id)

Set the ID entry in "/Root/FDF" dictionary.

##### Parameters

id | ID array object.

##### Throws

PDFNetException |

#### public void setPDFFileName (String filepath)

Set the PDF document file that this FDF file was exported from or is intended to be imported into.

##### Parameters

filepath | pathname to the file.

##### Throws

PDFNetException |