PdfFormField
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 (, , , etc.) for type-specific functionality.
from nutrient import PdfFormFieldMethods
get_child
def get_child(self, index: int) -> PdfFormFieldGets a child field by index.
Parameters:
| Name | Type | Description |
|---|---|---|
index | int | The 0-based index of the child field. |
Returns: PdfFormField - The child at the specified index. Raises:
IndexOutOfBoundsException: Thrown when index is out of range.
get_widget
def get_widget(self, index: int) -> PdfWidgetAnnotationGets a widget annotation by index.
Parameters:
| Name | Type | Description |
|---|---|---|
index | int | The 0-based index of the widget. |
Returns: PdfWidgetAnnotation - The at the specified index. Raises:
IndexOutOfBoundsException: Thrown when index is out of range.
remove_child_at
def remove_child_at(self, index: int) -> NoneRemoves 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. |
Raises:
IndexOutOfBoundsException: Thrown when index is out of range.SdkException: Thrown when the operation fails.
set_is_read_only
def set_is_read_only(self, value: bool) -> NoneSets whether the field is read-only.
Parameters:
| Name | Type | Description |
|---|---|---|
value | bool | The value to set for the IsReadOnly property. |
set_is_required
def set_is_required(self, value: bool) -> NoneSets whether the field is required.
Parameters:
| Name | Type | Description |
|---|---|---|
value | bool | The value to set for the IsRequired property. |
set_value
def set_value(self, value: str) -> NoneSets the current value of the field.
Parameters:
| Name | Type | Description |
|---|---|---|
value | str | The value to set for the Value property. |
Properties
child_count
@propertydef child_count(self) -> intGets the number of child fields.
Type: int
Read-only property.
default_value
@propertydef default_value(self) -> strGets the default value of the field.
Type: str
Read-only property.
field_type
@propertydef field_type(self) -> PdfFormFieldTypeGets the type of this form field.
Type: PdfFormFieldType
Read-only property.
full_name
@propertydef full_name(self) -> strGets the fully qualified name of this field (dot-separated path from root).
Type: str
Read-only property.
is_read_only
@propertydef is_read_only(self) -> boolGets whether the field is read-only.
Type: bool
Read-only property.
is_required
@propertydef is_required(self) -> boolGets whether the field is required.
Type: bool
Read-only property.
is_terminal
@propertydef is_terminal(self) -> boolGets whether this is a terminal field (has widget annotations instead of child fields). Terminal fields represent the actual interactive form elements.
Type: bool
Read-only property.
name
@propertydef name(self) -> strGets the partial name of this field (T entry).
Type: str
Read-only property.
parent
@propertydef parent(self) -> PdfFormFieldGets the parent field of this field, or null if this is a top-level field.
Type: PdfFormField
Read-only property.
value
@propertydef value(self) -> strGets the current value of the field.
Type: str
Read-only property.
widget_count
@propertydef widget_count(self) -> intGets the number of widget annotations.
Type: int
Read-only property.