Package com.snowtide.pdf.forms
Interface AcroForm
-
- All Superinterfaces:
Form<AcroFormField>
,Iterable<AcroFormField>
public interface AcroForm extends Form<AcroFormField>
A
Form
implementation that represents the contents of an interactive PDF form, available viaDocument.getFormData()
. All fields provided by aAcroForm
implement theAcroFormField
interface.Note that field names are mapped to
AcroFormField
instances using eachAcroFormField
'sfully-qualified name
. This is to ensure that one and only oneAcroFormField
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)
orwriteUpdatedDocument(OutputStream)
to write out an updated copy of the source PDF document.- Version:
- ©2004-2024 Snowtide
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AcroFormField
getField(String fullName)
Returns theAcroFormField
that has the given field name, as provided by theAcroFormField.getFullName()
function.byte[]
getXFAContents()
Returns the entire XFA contents of this form.byte[]
getXFAPacketContents(String packetName)
Returns the contents of the XML element referenced bypacketName
in this form.Set
getXFAPacketNames()
Returns aSet
of the packet names of the XFA data.Iterator<AcroFormField>
iterator()
Returns anIterator
over theAcroFormField
s held by this form.boolean
writeUpdatedDocument(File dest)
Identical functionality towriteUpdatedDocument(OutputStream)
, except the PDF document data is written to the path specified by the given File object.boolean
writeUpdatedDocument(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.boolean
writeUpdatedDocument(String destinationPath)
Identical functionality towriteUpdatedDocument(OutputStream)
, except the PDF document data is written to the path specified by the given String.-
Methods inherited from interface com.snowtide.pdf.forms.Form
getDocument, getFieldNames
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getField
AcroFormField getField(String fullName)
Returns theAcroFormField
that has the given field name, as provided by theAcroFormField.getFullName()
function.- Specified by:
getField
in interfaceForm<AcroFormField>
-
iterator
Iterator<AcroFormField> iterator()
Returns anIterator
over theAcroFormField
s held by this form.- Specified by:
iterator
in interfaceForm<AcroFormField>
- Specified by:
iterator
in interfaceIterable<AcroFormField>
-
writeUpdatedDocument
boolean writeUpdatedDocument(File dest) throws IOException
Identical functionality towriteUpdatedDocument(OutputStream)
, except the PDF document data is written to the path specified by the given File object.- Throws:
IOException
- Since:
- v2.1
- See Also:
writeUpdatedDocument(OutputStream)
-
writeUpdatedDocument
boolean writeUpdatedDocument(String destinationPath) throws IOException
Identical functionality towriteUpdatedDocument(OutputStream)
, except the PDF document data is written to the path specified by the given String.- Throws:
IOException
- Since:
- v3.0
- See Also:
writeUpdatedDocument(OutputStream)
-
writeUpdatedDocument
boolean writeUpdatedDocument(OutputStream dest) throws 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 theDocument
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:
IOException
- if an error occurs while writing the PDF document data- Since:
- v2.1
-
getXFAPacketNames
Set getXFAPacketNames() throws IOException
Returns aSet
of the packet names of the XFA data. Each of the Strings in that set may be passed togetXFAPacketContents(String)
to get the contents of that XML element.- Returns:
- a
Set
of String objects, corresponding to the packet names of XFA data - Throws:
IOException
- if an error occurs while reading the PDF document data
-
getXFAPacketContents
byte[] getXFAPacketContents(String packetName) throws IOException
Returns the contents of the XML element referenced bypacketName
in this form. To get a list of individual packets available in this form, you may callgetXFAPacketNames()
. IfpacketName
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:
IOException
- if an error occurs while reading the PDF document data
-
getXFAContents
byte[] getXFAContents() throws IOException
Returns the entire XFA contents of this form.- Returns:
- the XFA contents of this form
- Throws:
IOException
- if an error occurs while reading the PDF document data
-
-