Form

Overview

Form is a class in Aspose.PDF FOSS for Java. Inherits from: Iterable<Field>.

Represents the interactive form (AcroForm) of a PDF document (ISO 32000-1:2008, §12.7).

This class provides 26 methods for working with Form objects in Java programs. Available methods include: Form, add, delete, flatten, get, getCount, getDefaultAppearance, getDefaultResources, getFields, getFlattenSettings, getNeedAppearances, getPdfDictionary, and 9 additional methods. All public members are accessible to any Java application after installing the Aspose.PDF FOSS for Java package. Properties: count, defaultAppearance, defaultResources, fields, flattenSettings, needAppearances, and 3 more.

Properties

NameTypeAccessDescription
fieldsField[]ReadGet all fields
countintReadTotal field count
typeFormTypeReadForm type — detects XFA presence from the /XFA entry in the AcroForm dictionary.
xFAXfaFormReadReturns the XFA form object for accessing XFA-specific data.
needAppearancesbooleanRead/NeedAppearances
defaultAppearanceStringRead/DA — default appearance
defaultResourcesResourcesRead/DR — default resources
flattenSettingsFlattenSettingsReadReturns the flatten settings used by {@link #flatten()}.
pdfDictionaryPdfDictionaryReadGets the pdf dictionary.

Methods

SignatureDescription
Form(acroFormDict: PdfDictionary, document: Document, parser: PDFParser)Calls Form on this Form instance.
get(fieldName: String)FieldGet field by full name
hasField(fieldName: String)booleanReturns whether a field with the specified name exists.
hasField(fieldName: String, ignoreCase: boolean)booleanReturns whether a field with the specified name exists.
get(index: int)FieldGet field by 1-based index
getFields()Field[]Get all fields
getCount()intTotal field count
iterator()Iterator<Field>Calls iterator on this Form instance.
getType()FormTypeForm type — detects XFA presence from the /XFA entry in the AcroForm dictionary.
setType(type: FormType)Sets the form type.
getXFA()XfaFormReturns the XFA form object for accessing XFA-specific data.
getNeedAppearances()boolean/NeedAppearances
setNeedAppearances(value: boolean)Sets the need appearances value.
getDefaultAppearance()String/DA — default appearance
getDefaultResources()Resources/DR — default resources
add(field: Field)Add a field
add(field: Field, pageNumber: int)Adds a field to the specified page (1-based index).
add(field: Field, newName: String, pageNumber: int)FieldCreates a copy of the specified field, assigns it a new name, places it on the
requested page, and adds it to the form.
size()intReturns the number of fields in the form.
delete(fieldName: String)Delete field by name
flatten()Flattens the form by baking each field’s widget appearance into its page’s
content stream and then removing the AcroForm /Fields array.
flatten(settings: FlattenSettings)Flattens the form using the specified settings.
getFlattenSettings()FlattenSettingsReturns the flatten settings used by {@link #flatten()}.
setFlattenSettings(settings: FlattenSettings)Sets the flatten settings to be used by {@link #flatten()}.
getPdfDictionary()PdfDictionaryReturns the pdf dictionary.
invalidate()Drops the cached field index so the next field-access call rescans
{@code /AcroForm/Fields}.

See Also

 English