com.snowtide.pdf.forms
Interface AcroForm

All Superinterfaces:
Form

public interface AcroForm
extends Form

A Form implementation that represents the contents of an interactive PDF form, available via PDFTextStream.getFormData().

All FormField elements contained by an AcroForm shall also implement the AcroFormField interface.

Note that field names are mapped to AcroFormField instances using each AcroFormField's fully-qualified name. This is to ensure that one and only one AcroFormField is mapped to a particular field name, as provided for by the PDF specification.

Text, checkbox, radio button group, and choice fields may be updated. After updating such fields, simply call writeUpdatedDocument(File) or writeUpdatedDocument(OutputStream) as appropriate to write out an updated copy of the source PDF document.

Version:
©2004-2012 Snowtide Informatics Systems, Inc.

Method Summary
 FormField getField(java.lang.String fullName)
          Returns the AcroFormField that has the given field name, as provided by the AcroFormField.getFullName() function.
 java.util.Enumeration getFieldNames()
          Returns an Enumeration of the full field names (as provided by AcroFormField.getFullName()) of all of the form fields held by this form.
 byte[] getXFAContents()
          Returns the entire XFA contents of this form.
 byte[] getXFAPacketContents(java.lang.String packetName)
          Returns the contents of the XML element referenced by packetName in this form.
 java.util.Set getXFAPacketNames()
          Returns a Set of the packet names of the XFA data.
 boolean writeUpdatedDocument(java.io.File dest)
          Identical functionality to writeUpdatedDocument(OutputStream), except the PDF document data is written to the path specified by the given File object.
 boolean writeUpdatedDocument(java.io.OutputStream dest)
          If any field values contained in this form have been changed, then this function writes a copy of the PDF document from which this form was read to the given OutputStream, and appends the updated form field values.
 
Methods inherited from interface com.snowtide.pdf.forms.Form
iterator
 

Method Detail

getField

FormField getField(java.lang.String fullName)
Returns the AcroFormField that has the given field name, as provided by the AcroFormField.getFullName() function.

Specified by:
getField in interface Form

getFieldNames

java.util.Enumeration getFieldNames()
Returns an Enumeration of the full field names (as provided by AcroFormField.getFullName()) of all of the form fields held by this form. These names may be used as parameters into the getField(String) function.

Specified by:
getFieldNames in interface Form

writeUpdatedDocument

boolean writeUpdatedDocument(java.io.File dest)
                             throws java.io.IOException
Identical functionality to writeUpdatedDocument(OutputStream), except the PDF document data is written to the path specified by the given File object.

Throws:
java.io.IOException
Since:
v2.1
See Also:
writeUpdatedDocument(OutputStream)

writeUpdatedDocument

boolean writeUpdatedDocument(java.io.OutputStream dest)
                             throws java.io.IOException
If any field values contained in this form have been changed, then this function writes a copy of the PDF document from which this form was read to the given OutputStream, and appends the updated form field values. In this case, this function will always return true. If no field values have been changed, then this function will do nothing, and return false. This function will fail with an exception if the PDFTextStream instance from which this form instance was retrieved has been closed.

Parameters:
dest - - the OutputStream to which the updated PDF document data will be written
Returns:
- true if any field values in this form have been changed, and updated PDF document data has been written to the given OutputStream; if no field values have been changed, then no data will be written, and false is returned
Throws:
java.io.IOException - - if an error occurs while writing the PDF document data
Since:
v2.1

getXFAPacketNames

java.util.Set getXFAPacketNames()
                                throws java.io.IOException
Returns a Set of the packet names of the XFA data. Each of the Strings in that set may be passed to getXFAPacketContents(String) to get the contents of that XML element.

Returns:
a Set of String objects, corresponding to the packet names of XFA data
Throws:
java.io.IOException - - if an error occurs while reading the PDF document data

getXFAPacketContents

byte[] getXFAPacketContents(java.lang.String packetName)
                            throws java.io.IOException
Returns the contents of the XML element referenced by packetName in this form. To get a list of individual packets available in this form, you may call getXFAPacketNames(). If packetName does not exist in this form, null is returned.

Parameters:
packetName - - the name of the XML packet to be extracted from this form
Returns:
- the XML contents of the given packet
Throws:
java.io.IOException - - if an error occurs while reading the PDF document data

getXFAContents

byte[] getXFAContents()
                      throws java.io.IOException
Returns the entire XFA contents of this form.

Returns:
- the XFA contents of this form
Throws:
java.io.IOException - - if an error occurs while reading the PDF document data