Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

PdfAcroFormField Class

Represents the base class for all interactive form fields.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v20.2.Core.dll

NuGet Package: DevExpress.Pdf.Core

Declaration

public abstract class PdfAcroFormField

Remarks

The table below lists available form fields and API used to create each type.

Form Field Class Method
Check Box PdfAcroFormCheckBoxField PdfAcroFormField.CreateCheckBox
Combo box PdfAcroFormComboBoxField PdfAcroFormField.CreateComboBox
Group PdfAcroFormGroupField PdfAcroFormField.CreateGroup
List Box PdfAcroFormListBoxField PdfAcroFormField.CreateListBox
Radio Group PdfAcroFormRadioGroupField PdfAcroFormField.CreateRadioGroup
Signature PdfAcroFormSignatureField PdfAcroFormField.CreateSignature
Text Box PdfAcroFormTextBoxField PdfAcroFormField.CreateTextBox

Example

This example shows how to create text box and radio button group fields and add them to a document.

using DevExpress.Pdf;

namespace AddFormFieldsToExistingDocument {
    class Program {
        static void Main(string[] args) {
            using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
            {
                // Load a document.
                processor.LoadDocument("..\\..\\Document.pdf");

                // Create a text box field specifying the field name, page number, and field location on the page.
                PdfAcroFormTextBoxField textBox = new PdfAcroFormTextBoxField("text box", 1, new PdfRectangle(230, 690, 280, 710));

                // Specify text box text, and appearance.
                textBox.Text = "Text Box";
                textBox.Appearance.BackgroundColor = new PdfRGBColor(0.8, 0.5, 0.3);
                textBox.Appearance.FontSize = 12;

                // Create a radio group field specifying its name and the page number.
                PdfAcroFormRadioGroupField radioGroup = new PdfAcroFormRadioGroupField("Gender Group", 1);

                // Add the first radio button to the group and specify its location using a PdfRectangle object.
                radioGroup.AddButton("button1", new PdfRectangle(230, 635, 250, 655));

                // Add the second radio button to the group.
                radioGroup.AddButton("button2", new PdfRectangle(310, 635, 330, 655));

                // Specify radio group selected index, and appearance.
                radioGroup.SelectedIndex = 0;
                radioGroup.Appearance.BorderAppearance = new PdfAcroFormBorderAppearance()
                { Color = new PdfRGBColor(0.8, 0.5, 0.3), Width = 3 };

                // Add form fields to the page.
                processor.AddFormFields(textBox, radioGroup);

                // Save the result document.
                processor.SaveDocument("..\\..\\Result.pdf");
            }
        }
    }
}
See Also