Package com.snowtide.pdf.forms
Interface AcroForm
-
- All Superinterfaces:
Form<AcroFormField>,Iterable<AcroFormField>
public interface AcroForm extends Form<AcroFormField>
A
Formimplementation that represents the contents of an interactive PDF form, available viaDocument.getFormData(). All fields provided by aAcroFormimplement theAcroFormFieldinterface.Note that field names are mapped to
AcroFormFieldinstances using eachAcroFormField'sfully-qualified name. This is to ensure that one and only oneAcroFormFieldis 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-2025 Snowtide
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AcroFormFieldgetField(String fullName)Returns theAcroFormFieldthat 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 bypacketNamein this form.SetgetXFAPacketNames()Returns aSetof the packet names of the XFA data.Iterator<AcroFormField>iterator()Returns anIteratorover theAcroFormFields held by this form.booleanwriteUpdatedDocument(File dest)Identical functionality towriteUpdatedDocument(OutputStream), except the PDF document data is written to the path specified by the given File object.booleanwriteUpdatedDocument(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.booleanwriteUpdatedDocument(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 theAcroFormFieldthat has the given field name, as provided by theAcroFormField.getFullName()function.- Specified by:
getFieldin interfaceForm<AcroFormField>
-
iterator
Iterator<AcroFormField> iterator()
Returns anIteratorover theAcroFormFields held by this form.- Specified by:
iteratorin interfaceForm<AcroFormField>- Specified by:
iteratorin 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 theDocumentfrom 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 aSetof 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
Setof 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 bypacketNamein this form. To get a list of individual packets available in this form, you may callgetXFAPacketNames(). IfpacketNamedoes 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 IOExceptionReturns 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
-
-