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
| Name | Type | Access | Description |
|---|---|---|---|
fields | Field[] | Read | Get all fields |
count | int | Read | Total field count |
type | FormType | Read | Form type — detects XFA presence from the /XFA entry in the AcroForm dictionary. |
xFA | XfaForm | Read | Returns the XFA form object for accessing XFA-specific data. |
needAppearances | boolean | Read | /NeedAppearances |
defaultAppearance | String | Read | /DA — default appearance |
defaultResources | Resources | Read | /DR — default resources |
flattenSettings | FlattenSettings | Read | Returns the flatten settings used by {@link #flatten()}. |
pdfDictionary | PdfDictionary | Read | Gets the pdf dictionary. |
Methods
| Signature | Description |
|---|---|
Form(acroFormDict: PdfDictionary, document: Document, parser: PDFParser) | Calls Form on this Form instance. |
get(fieldName: String) → Field | Get field by full name |
hasField(fieldName: String) → boolean | Returns whether a field with the specified name exists. |
hasField(fieldName: String, ignoreCase: boolean) → boolean | Returns whether a field with the specified name exists. |
get(index: int) → Field | Get field by 1-based index |
getFields() → Field[] | Get all fields |
getCount() → int | Total field count |
iterator() → Iterator<Field> | Calls iterator on this Form instance. |
getType() → FormType | Form type — detects XFA presence from the /XFA entry in the AcroForm dictionary. |
setType(type: FormType) | Sets the form type. |
getXFA() → XfaForm | Returns 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) → Field | Creates a copy of the specified field, assigns it a new name, places it on the |
| requested page, and adds it to the form. | |
size() → int | Returns 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() → FlattenSettings | Returns the flatten settings used by {@link #flatten()}. |
setFlattenSettings(settings: FlattenSettings) | Sets the flatten settings to be used by {@link #flatten()}. |
getPdfDictionary() → PdfDictionary | Returns the pdf dictionary. |
invalidate() | Drops the cached field index so the next field-access call rescans |
| {@code /AcroForm/Fields}. |