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

NameTypeAccessDescription
FieldsField[]ReadReturns the form fields as a snapshot array (Field[] Fields), so callers can use .Length and array indexing.
IgnoreNeedsRenderingboolRead/WriteWhen true, the form’s NeedAppearances entry is suppressed so Acrobat won’t rebuild widget appearances at open time.
EmulateRequierdGroupsboolRead/WriteWhen true, the form’s flatten step adds a synthetic Required marker for XFA-style ‘requiredGroups’ whose at-least-one-required constraint is unmet.
CountintReadGets the count.
RadioGroupsIReadOnlyList<RadioButtonGroup>ReadAll radio-button groups in the form.
SignaturesExistboolRead/WriteTrue if any signature field with a non-null /V signature dictionary exists in this form.
TypeFormTypeRead/WriteThe form type (Standard, Static, Dynamic).
IsXfaboolReadWhether this form is an XFA form.
XFAXFA?ReadXFA accessor exposing the underlying XML packets (template, datasets, …).
HasXfaboolReadTrue when the form contains an XFA part.
AutoRecalculateboolRead/WriteWhen true, recalculate calculated fields whenever a dependency changes.
AutoRestoreFormboolRead/WriteWhen true, the form auto-restores its default values on Reset.
CalculatedFieldsIEnumerable<Field>?Read/WriteThe field order used to drive calculation passes.
DefaultAppearanceAspose.Pdf.Annotations.DefaultAppearanceRead/WriteDefault appearance applied to fields that don’t carry their own /DA.
DefaultResourcesAspose.Pdf.Resources?ReadDefault font / colorspace resources used by the form.
IsSynchronizedboolReadWhether the underlying collection is thread-safe.
NeedsRenderingboolReadTrue when the form has the NeedsAppearances flag set.
RemovePermissionboolRead/WriteWhen true, the document’s permission bits are stripped before saving.
SignaturesAppendOnlyboolRead/WriteWhen true, the writer ignores signature-bypassing modifications.
SyncRootobjectReadSynchronization root object for IsSynchronized.

Methods

SignatureDescription
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.

See Also