Form
Overview
Form is a class in Aspose.PDF FOSS for .NET.
Inherits from: IEnumerable<Aspose.Pdf.Annotations.WidgetAnnotation>.
Represents the interactive form (AcroForm) of a PDF document.
This class provides 36 methods for working with Form objects in .NET programs.
Available methods include: Add, AddFieldAppearance, AssignXfa, CopyTo, Delete, ExportFdf, ExportToJson, ExportXfdf, FindByName, FindField, Flatten, Form, and 14 additional methods.
All public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package.
Properties: AutoRecalculate, AutoRestoreForm, CalculatedFields, Count, DefaultAppearance, DefaultResources, and 14 more.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
Fields | Field[] | Read | Returns the form fields as a snapshot array (Field[] Fields), so callers can use .Length and array indexing. |
IgnoreNeedsRendering | bool | Read/Write | When true, the form’s NeedAppearances entry is suppressed so Acrobat won’t rebuild widget appearances at open time. |
EmulateRequierdGroups | bool | Read/Write | When true, the form’s flatten step adds a synthetic Required marker for XFA-style ‘requiredGroups’ whose at-least-one-required constraint is unmet. |
Count | int | Read | Gets the count. |
RadioGroups | IReadOnlyList<RadioButtonGroup> | Read | All radio-button groups in the form. |
SignaturesExist | bool | Read/Write | True if any signature field with a non-null /V signature dictionary exists in this form. |
Type | FormType | Read/Write | The form type (Standard, Static, Dynamic). |
IsXfa | bool | Read | Whether this form is an XFA form. |
XFA | XFA? | Read | XFA accessor exposing the underlying XML packets (template, datasets, …). |
HasXfa | bool | Read | True when the form contains an XFA part. |
AutoRecalculate | bool | Read/Write | When true, recalculate calculated fields whenever a dependency changes. |
AutoRestoreForm | bool | Read/Write | When true, the form auto-restores its default values on Reset. |
CalculatedFields | IEnumerable<Field>? | Read/Write | The field order used to drive calculation passes. |
DefaultAppearance | Aspose.Pdf.Annotations.DefaultAppearance | Read/Write | Default appearance applied to fields that don’t carry their own /DA. |
DefaultResources | Aspose.Pdf.Resources? | Read | Default font / colorspace resources used by the form. |
IsSynchronized | bool | Read | Whether the underlying collection is thread-safe. |
NeedsRendering | bool | Read | True when the form has the NeedsAppearances flag set. |
RemovePermission | bool | Read/Write | When true, the document’s permission bits are stripped before saving. |
SignaturesAppendOnly | bool | Read/Write | When true, the writer ignores signature-bypassing modifications. |
SyncRoot | object | Read | Synchronization root object for IsSynchronized. |
Methods
| Signature | Description |
|---|---|
Form(document: Document) | Construct a Form bound to document. |
Delete(fieldName: string) | Delete a form field by name. |
Add(field: Field) | Add a field to the form on the specified page. |
Add(field: Field, pageNumber: int) | The field to add. |
findField(fullName: string) | Look up a field by name; returns null when not found. |
FindField(fullName: string) | PascalCase alias of findField. |
ToObject() | Export all field values as a dictionary (field name → value). |
HasField(fieldName: string) | True if a field with the given full name exists in the AcroForm. |
HasField(fieldName: string, searchChildren: bool) | True if a field with the given name exists. |
FindByName(fullName: string) | Find a field by its full name, or by XFA path for static XFA forms. |
GetXfaDatasetsXml() | Get the XFA datasets XML, or null if not an XFA form. |
GetXfaFieldValue(path: string) | Get an XFA field value by dotted path in the datasets XML. |
SetXfaFieldValue(path: string, value: string) | Set an XFA field value by dotted path in the datasets XML. |
SetXfaFieldValues(values: IReadOnlyList<KeyValuePair<string, string>>) | Set several XFA field values in one datasets parse/serialise cycle. |
Flatten() | Flatten all form fields — render their visual appearance into page content and remove the interactive form. |
Flatten(document: Document) | Flatten all form fields — render their visual appearance into page content and remove the interactive form. |
ExportFdf() | Export form field data in FDF (Forms Data Format) per PDF spec §12.7.7. |
ImportFdf(fdfData: byte[]) | Import form field data from FDF bytes. |
ExportXfdf() | Export form field data in XFDF (XML Forms Data Format). |
ImportXfdf(xfdfXml: string) | Import form field data from XFDF XML string. |
GetEnumerator() | Calls GetEnumerator on this Form instance. |
Add(field: Field, partialName: string, pageNumber: int) | Copy field into the form under a new partial name, binding its widget(s) to pageNumber. |
AddFieldAppearance(field: Field, pageNumber: int, rect: Rectangle) | Append a fresh widget appearance to a field on a specific page within a rectangle. |
AssignXfa(xml: XmlDocument) | Replace the XFA datasets from the given XmlDocument. |
CopyTo(array: Field[], index: int) | Copy fields into the supplied array starting at index. |
Delete(field: Field) | Remove the supplied field from the form. |
ExportToJson(stream: Stream) | Serialize the form’s fields to JSON via the supplied stream. |
ExportToJson(fileName: string) | Serialize the form’s fields to JSON in a file. |
ExportToJson(stream: Stream, options: ExportFieldsToJsonOptions?) | Serialize the form’s fields to JSON via the supplied stream. |
ExportToJson(fileName: string, options: ExportFieldsToJsonOptions?) | Serialize the form’s fields to JSON in a file. |
GetFieldsInRect(rect: Rectangle) | Return the fields that intersect the supplied rectangle. |
HasField(field: Field) | True when the supplied field belongs to this form. |
ImportFromJson(stream: Stream) | Read form-field values from a JSON stream and apply them. |
ImportFromJson(fileName: string) | Read form-field values from a JSON file and apply them. |
MakeFormAnnotationsIndependent(page: Page) | Detach form annotations from the field tree so they can be moved between pages independently. |
RemoveFieldAppearance(field: Field, appearanceIndex: int) | Remove a specific appearance entry from a field. |