PdfFormField Class

A field of the interactive form of a document (ISO 32000-2, 12.7.4): a node of the field hierarchy. A terminal field has a value and widgets, the annotations that show it on the pages; a non-terminal field holds other fields, whose names are qualified by its name.

public class PdfFormField

Remarks

The derived classes represent the terminal fields of each type: PdfTextField, PdfCheckBoxField, PdfRadioButtonField, PdfPushButtonField, PdfChoiceField and PdfSignatureField. The other fields (non-terminal fields, unknown types) are of this class.

Properties

NameDescription
AlternateNameGets or sets the alternate name of the field (/TU): the text the user interface shows, and assistive technologies read.
ChildrenGets the child fields, for a non-terminal field.
DictionaryGets the field dictionary. For a field with one widget, it can also be the widget annotation (a merged dictionary).
FieldTypeGets the field type (/FT, inherited): Tx, Btn, Ch or Sig, or null for a non-terminal field without type.
FlagsGets or sets the flags of the field (/Ff, inherited, 12.7.4.1 and the tables of the field types).
FormGets the form of the field.
FullNameGets the fully qualified name of the field: the partial names of the field and its ancestors, separated by periods (12.7.4.2).
IsReadOnlyGets or sets a value indicating whether the user cannot change the value of the field (bit 1 of PdfFormField.Flags).
IsRequiredGets or sets a value indicating whether the field must have a value when the form is submitted (bit 2 of PdfFormField.Flags).
IsTerminalGets a value indicating whether the field is a terminal field: it has no child fields.
NameGets the partial name of the field (/T).
ParentGets the parent field, or null for a field at the top of the hierarchy.
ReferenceGets the reference to the field dictionary, or null for a direct object.
ValueGets or sets the value of the field (/V, inherited) as a text: a text string or a name; null when it has none.
WidgetsGets the widgets of the field: the annotations that show it on the pages. A widget that is on no page is left out.

AlternateName

PdfFormField.cs

Gets or sets the alternate name of the field (/TU): the text the user interface shows, and assistive technologies read.

public string? AlternateName { get; set; }

Property value

string?

Gets the child fields, for a non-terminal field.

public IReadOnlyList<PdfFormField> Children { get; }

Dictionary

PdfFormField.cs

Gets the field dictionary. For a field with one widget, it can also be the widget annotation (a merged dictionary).

public PdfDictionary Dictionary { get; }

Property value

PdfDictionary

Gets the field type (/FT, inherited): Tx, Btn, Ch or Sig, or null for a non-terminal field without type.

public string? FieldType { get; }

Property value

string?

Gets or sets the flags of the field (/Ff, inherited, 12.7.4.1 and the tables of the field types).

public int Flags { get; set; }

Property value

int

Gets the form of the field.

public PdfInteractiveForm Form { get; }

Property value

PdfInteractiveForm

Gets the fully qualified name of the field: the partial names of the field and its ancestors, separated by periods (12.7.4.2).

public string FullName { get; }

Property value

string

IsReadOnly

PdfFormField.cs

Gets or sets a value indicating whether the user cannot change the value of the field (bit 1 of PdfFormField.Flags).

public bool IsReadOnly { get; set; }

Property value

bool

IsRequired

PdfFormField.cs

Gets or sets a value indicating whether the field must have a value when the form is submitted (bit 2 of PdfFormField.Flags).

public bool IsRequired { get; set; }

Property value

bool

IsTerminal

PdfFormField.cs

Gets a value indicating whether the field is a terminal field: it has no child fields.

public bool IsTerminal { get; }

Property value

bool

Gets the partial name of the field (/T).

public string Name { get; }

Property value

string

Gets the parent field, or null for a field at the top of the hierarchy.

public PdfFormField? Parent { get; }

Property value

PdfFormField?

Gets the reference to the field dictionary, or null for a direct object.

public PdfReference? Reference { get; }

Property value

PdfReference?

Gets or sets the value of the field (/V, inherited) as a text: a text string or a name; null when it has none.

public virtual string? Value { get; set; }

Property value

string?

Exceptions

NotSupportedException
The value of the field cannot be set: a push button, a signature field, a non-terminal field or a field of an unknown type.

Remarks

The value of a text field, a choice field, a check box (its on state or Off) and a group of radio buttons (its option) can be set; their appearances are updated.

Gets the widgets of the field: the annotations that show it on the pages. A widget that is on no page is left out.

public IReadOnlyList<PdfAnnotation> Widgets { get; }