Spire.PDF 12.10.7 adds support for PDF form fields and XFA forms

2026-10-27 07:11:25

We’re pleased to announce the release of Spire.PDF 12.10.7. This version introduces a new namespace for comprehensive PDF form processing, providing APIs for creating, reading, modifying, and flattening form fields. It also extends support to XFA forms and enables form data import and export in XML, FDF, and XFDF formats. These enhancements provide developers with more flexible and efficient ways to work with interactive PDF forms.

Here is a list of changes made in this release

Category ID Description
New Feature - Added the Spire.Pdf.Interactive.Forms namespace to support creating, reading, modifying, and flattening AcroForm fields.
New Feature - Added support for accessing and processing XFA forms through the Spire.Pdf.Interactive.Forms.Xfa namespace.
New Feature - Added support for importing and exporting PDF form data in XML, FDF, and XFDF formats through PdfForm.

1. Added the Spire.Pdf.Interactive.Forms namespace

The new Spire.Pdf.Interactive.Forms namespace provides a unified and comprehensive API for creating, reading, modifying, and flattening PDF form fields. It covers the common AcroForm field types, with the following key properties and methods.

Supported AcroForm Field Types

Field Type Property / Method Description
Text field PdfTextField IsMultiline Whether multi-line input is allowed
IsPassword Displayed as a mask (password field)
MaxLen Maximum number of characters allowed
IsComb Uses character comb cells
DoNotSpellCheck Disables spell checking
Text The text content of the field
Font Field font
Check box PdfCheckBoxField IsChecked Whether it is currently checked
OnValue Export value for the checked state
Style Visual style (Check/Circle/Cross/Diamond/Square/Star)
Radio button PdfRadioButtonField Options Collection of export values for the options
SelectedIndex Index of the currently selected option
SelectedValue Export value of the currently selected option
NoToggleToOff Whether deselecting is disabled once selected
AddOption() Adds a new radio option to the page
Combo box PdfComboBoxField Items Collection of drop-down options
IsMultiSelect Whether multiple selection is allowed
SelectedIndex Index of the currently selected option
SelectedValue Export value of the currently selected option
CascadeTo() Establishes a JavaScript cascade with another combo box
List box PdfListBoxField Items Collection of list options
IsMultiSelect Whether multiple selection is allowed
TopIndex Index of the first visible list option
SelectedIndices Collection of indices of the selected options
SelectedValues Collection of export values of the selected options
Push button PdfPushButtonField Text / RolloverText / DownText Button text for the normal / rollover / down states
Icon / RolloverIcon / DownIcon Display icons for the corresponding three states
Layout Layout of the icon and text
Action Action executed when the button is clicked
Signature field PdfSignatureField Signature Digital signature object associated with the field

In addition to the field-specific members listed above, all fields inherit common properties from PdfField, including:

  • IsReadOnly: Specifies whether the field is read-only.
  • IsRequired: Specifies whether the field is required.
  • AlternateName: Gets or sets the alternate name of the field.
  • MappingName: Gets or sets the mapping name of the field.
  • DefaultAppearance: Gets or sets the default appearance of the field.

All fields can also call Flatten() to flatten the form field into static page content.


2. Extended Support for XFA Forms

This version also introduces access to XFA forms through the Spire.Pdf.Interactive.Forms.Xfa sub-namespace. Developers can retrieve XFA form field names and objects, inspect field values, and work with a variety of XFA field types.

Supported AcroForm Field Types

Field Type Property / Method Description
XFA form XfaForm FieldNames List of field names in the form template
XfaFields List of field objects in the form template
Count Number of form fields
GetField(name) Gets an XFA field by name
CheckFieldExists(name) Checks whether the specified field exists
Text XfaTextField Value Text value of the field
Numeric XfaNumericField Format Numeric format string
Value Field value (decimal)
Check box XfaCheckBoxField IsChecked Whether it is currently checked
Radio button XfaRadioButtonField Options List of export values for the options
SelectedIndex Index of the currently selected option
SelectedValue Export value of the currently selected option
NoToggleOff Whether deselecting is disabled once selected
Choice list XfaChoiceField Items List of available items (display values)
IsMultiSelect Whether multiple selection is supported
SelectedItem Currently selected single item
SelectedItems List of currently selected items
Date/time XfaDateTimeField Value Date/time value of the field
Image XfaImageField Image Image of the field (Stream / Image)
Barcode XfaBarcodeField Value Barcode value
Length Barcode length
StartChar Barcode start character
EndChar Barcode end character

All XFA fields inherit common properties from XfaField, including:

  • Name: The field name.
  • XfaForm: The containing XFA form.
  • FieldType: The field type identifier.

The XfaSignatureField (signature) and XfaPushButtonField (push button) classes do not define additional public properties and are accessed primarily through their inherited common members.


3. Added Form Data Import and Export

PdfForm now supports importing and exporting form data in XML, FDF, and XFDF formats. This functionality facilitates form data exchange between PDF documents, business systems, and third-party PDF tools.

Code example:

using System.Drawing;
  using System.Collections.Generic;
  using Spire.Pdf;
  using Spire.Pdf.Graphics;
  using Spire.Pdf.Interactive.Forms;

  PdfDocument doc = new PdfDocument();
  PdfPageBase page = doc.Pages.Add();

  // Get the form container via PdfForm.Create() under the new namespace
  PdfForm form = PdfForm.Create(doc);

  // Create a text field and add it to the page
  PdfTextField nameField = new PdfTextField(form, "Address.Street");
  nameField.DefaultAppearance = new PdfDefaultAppearance(
      new PdfFont(PdfFontFamily.Helvetica, 12), new PdfRGBColor(0, 0, 0));
  nameField.AddWidget(page, new RectangleF(100, 100, 250, 30));
  nameField.Value = "123 Main St";

  // Retrieve fields by name and by prefix
  PdfField field = form.GetField("Address.Street");
  List<PdfField> addressFields = form.Fields.FindByPrefix("Address");

  // Flatten to static content and save
  form.Flatten();
  doc.SaveToFile("output.pdf");

  Form data can also be exchanged directly in formats such as XFDF:
  // Export form data as XFDF and import it back from the file
  form.ExportData("form.xfdf", DataFormat.XFDF, "PurchaseOrder");
  form.ImportData("form.xfdf", DataFormat.XFDF);

Click the link below to download Spire.PDF 12.10.7:
More information of Spire.PDF new release or hotfix: