Represents a form field in a PDF document. Form fields can be terminal (with widget annotations) or non-terminal (with child fields). This is the base class for all form field types. Use the specific subclasses (PdfTextField, PdfCheckBoxField, PdfRadioButtonField, etc.) for type-specific functionality.
using Nutrient;The SDK creates this class through factory methods or other SDK objects.
Properties
ChildCount
public int ChildCount { get; }The number of child fields.
Type: int
DefaultValue
public string DefaultValue { get; }The default value of the field.
Type: string
FieldType
public PdfFormFieldType FieldType { get; }The type of this form field.
Type: PdfFormFieldType
FullName
public string FullName { get; }The fully qualified name of this field (dot-separated path from root).
Type: string
IsReadOnly
public bool IsReadOnly { get; set; }Whether the field is read-only.
Type: bool
IsRequired
public bool IsRequired { get; set; }Whether the field is required.
Type: bool
IsTerminal
public bool IsTerminal { get; }Whether this is a terminal field (has widget annotations instead of child fields). Terminal fields represent the actual interactive form elements.
Type: bool
Name
public string Name { get; }The partial name of this field (T entry).
Type: string
Parent
public PdfFormField? Parent { get; }The parent field of this field, or null if this is a top-level field.
Type: PdfFormField?
Value
public string Value { get; set; }The current value of the field.
Type: string
WidgetCount
public int WidgetCount { get; }The number of widget annotations.
Type: int
Methods
GetChild
public PdfFormField GetChild(int index)Gets a child field by index.
Parameters
| Name | Type | Description |
|---|---|---|
index | int | The 0-based index of the child field. |
Returns: PdfFormField - The child PdfFormField at the specified index. Throws: NutrientException - Thrown when index is out of range.
GetWidget
public PdfWidgetAnnotation GetWidget(int index)Gets a widget annotation by index.
Parameters
| Name | Type | Description |
|---|---|---|
index | int | The 0-based index of the widget. |
Returns: PdfWidgetAnnotation - The PdfWidgetAnnotation at the specified index. Throws: NutrientException - Thrown when index is out of range.
RemoveChildAt
public void RemoveChildAt(int index)Removes a child field at the specified index. Also removes any grandchild fields and associated widget annotations.
Parameters
| Name | Type | Description |
|---|---|---|
index | int | The 0-based index of the child field to remove. |
Throws: NutrientException - Thrown when index is out of range.
Throws: NutrientException - Thrown when the operation fails.
Resource management
public void Dispose()PdfFormField implements IDisposable. Call Dispose() or use a C# using declaration to release its native handle right away. If you don’t, the handle is released when the object is garbage collected.