Form
Overview
Form is a class in Aspose.PDF FOSS for .NET.
Inherits from: IDisposable.
Facade for form field manipulation including XML import/export.
This class provides 54 methods for working with Form objects in .NET programs.
Available methods include: BindPdf, Close, Dispose, ExportFdf, ExportJson, ExportXfdf, ExportXml, ExtractXfaData, FillBarcodeField, FillField, FillFields, FillImageField, and 23 additional methods.
All public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package.
Properties: ConvertTo, DestFileName, DestStream, Document, FieldNames, FormSubmitButtonNames, and 3 more.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
ImportResult | FormImportResult[] | Read | Per-field outcomes from the most recent ImportFdf/ ImportXfdf/ImportXml call. |
Document | Document? | Read | The underlying document. |
FormSubmitButtonNames | string[] | Read | Get the names of submit buttons in the form. |
SrcFileName | string? | Read/Write | Source file name. |
SrcStream | Stream? | Read/Write | Source stream. |
ConvertTo | Aspose.Pdf.PdfFormat | Read/Write | Target PDF/A or PDF version for the saved output. |
FieldNames | string[] | Read | Get all field names in the form. |
DestFileName | string? | Read/Write | Destination file name for saving. |
DestStream | Stream? | Read/Write | Destination stream for saving. |
Methods
| Signature | Description |
|---|---|
Form() | Create an unbound Form facade. |
Form(document: Document) | Create a Form facade bound to a document. |
Form(document: Document, destStream: Stream) | Bind a Document and pre-configure an output stream for the parameterless Save. |
Form(document: Document, destFileName: string) | Bind a Document and pre-configure an output file path for the parameterless Save. |
Form(srcFileName: string, destFileName: string) | Create a Form facade from input and output file paths. |
Form(srcFileName: string, destStream: Stream) | Create a Form facade from an input file, writing to a stream on Save. |
Form(srcFileName: string) | Create a Form facade from an input file path. |
Form(srcStream: Stream) | Create a Form facade from a stream. |
Form(srcStream: Stream, destStream: Stream) | Create a Form facade from a source stream, writing to a destination stream on Save. |
Form(srcStream: Stream, destFileName: string) | Create a Form facade from a source stream, writing to a destination file on Save. |
BindPdf(path: string) | Bind a PDF file to this facade. |
BindPdf(doc: Document) | Bind a document to this facade. |
BindPdf(stream: Stream) | Bind a PDF stream to this facade. |
GetFieldLimit(fieldName: string) | Get the maximum character count of a text field by name. |
GetField(fieldName: string) | Get a field value by name. |
FillField(fieldName: string, fieldValue: string) | Fill a field with a value. |
FillField(fieldName: string, beChecked: bool) | Fill a field with a boolean value (for checkboxes/radio buttons). |
GetFieldType(fieldName: string) | Get the type of a field by name. |
GetFieldFacade(fieldName: string) | Get visual facade properties for a field. |
GetButtonOptionCurrentValue(fieldName: string) | Get the current value of a button (radio button) field. |
GetButtonOptionValues(fieldName: string) | Get the option values of a button (radio button) field. |
GetFullFieldName(fieldName: string) | Get the full qualified field name. |
FlattenField(fieldName: string) | Flatten a specific field by name — render it as static content and remove interactive state. |
FlattenAllFields() | Flatten all form fields in the document — render them as static content and remove the AcroForm. |
ImportXml(inputXmlStream: Stream, IgnoreFormTemplateChanges: bool) | Import form field values from an XML stream. |
ImportXfdf(inputXfdfStream: Stream) | Import form field data from an XFDF stream. |
ImportFdf(inputFdfStream: Stream) | Import form field data from an FDF stream. |
ExportXml(outputXmlStream: Stream) | Export form field values to an XML stream. |
ExportFdf(outputFdfStream: Stream) | Export form field values as FDF to a stream. |
ExportXfdf(outputXfdfStream: Stream) | Export form field values as XFDF to a stream. |
ExportJson(outputJsonStream: Stream, indented: bool) | Exports the contents of all fields in the document into a JSON stream. |
ImportJson(inputJsonStream: Stream) | Imports field values from a JSON stream into the bound document, matching fields by their full names. |
HasField(fullName: string) | True if a field with the given full name exists in the bound form. |
Save() | Save the modified document. |
Save(destFile: string) | Save to a specific path. |
Save(destStream: Stream) | Save the modified document to a stream. |
SaveBytes() | Save the modified document and return bytes. |
Close() | Close the facade. |
Dispose() | Calls Dispose on this Form instance. |
ExtractXfaData(outputXmlStream: Stream) | Extract the document’s XFA datasets XML to a stream. |
SetXfaData(inputXmlStream: Stream) | Replace the document’s XFA datasets XML from a stream. |
FillBarcodeField(fieldName: string, data: string) | Fill a barcode field by name with the given data. |
FillField(fieldName: string, value: string, fitFontSize: bool) | Fill a text field with the supplied value, optionally fitting font size to the box. |
FillField(fieldName: string, index: int) | Fill a choice field by selected-option index. |
FillField(fieldName: string, fieldValues: string[]) | Fill a list-box field with the supplied multi-select values. |
FillFields(fieldNames: string[], fieldValues: string[], output: Stream) | Apply multiple field values and return the resulting PDF as a stream. |
FillImageField(fieldName: string, imageStream: Stream) | Fill an image-button field from a stream. |
FillImageField(fieldName: string, imageFileName: string) | Fill an image-button field from a file path. |
GetFieldFlag(fieldName: string) | Get the PropertyFlag set on a field (ReadOnly / Required / NoExport). |
GetRichText(fieldName: string) | Return the field’s rich-text contents (the /RV entry) or null when absent. |
GetSubmitFlags(fieldName: string) | Return the SubmitFormFlag recorded on a submit-button field. |
IsRequiredField(fieldName: string) | True when the field has the Required flag set. |
RenameField(fieldName: string, newFieldName: string) | Rename a form field. |
ImportXml(inputXmlStream: Stream) | Import form field values from an XML stream (parameterless overload — same as ImportXml(Stream, bool) with ignoreFormTemplateChanges=false). |