Form
Overview
Form is a class in Aspose.PDF FOSS for Python.
Represents an interactive form (AcroForm) within a PDF document.
This class provides 10 methods for working with Form objects in Python programs.
Available methods include: __init__, add_checkbox, add_combo_box, add_list_box, add_push_button, add_radio_group, add_text_field, flatten, generate_appearances, remove_field.
All public members are accessible to any Python application after installing the Aspose.PDF FOSS for Python package.
Properties: fields.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
fields | list[Field] | Read | A list of all fields in the form. |
Methods
| Signature | Description |
|---|---|
__init__(document: Document) | Calls init(document) on this Form instance. |
add_text_field(name: str, page: Any, rect: Sequence[float], value: str, font_size: float, multiline: bool, alignment: str | int, read_only: bool, required: bool) → Field | Add an editable text field and return it. |
add_checkbox(name: str, page: Any, rect: Sequence[float], checked: bool, on_value: str, read_only: bool, required: bool) → Field | Add a check box with generated Off/on appearances. |
| `add_radio_group(name: str, page: Any, options: Mapping[str, Sequence[float]] |
\| Sequence[tuple[str, Sequence[float]]], value: str \| None, read_only: bool, required: bool)` → `Field` | Add a radio field whose option names map to widget rectangles. |
| add_list_box(name: str, page: Any, rect: Sequence[float], options: Sequence[str \| tuple[str, str]], value: str \| Sequence[str] \| None, multiselect: bool, font_size: float, alignment: str \| int, read_only: bool, required: bool) → Field | Add a list box with string or export/display options. |
| add_combo_box(name: str, page: Any, rect: Sequence[float], options: Sequence[str \| tuple[str, str]], value: str \| None, editable: bool, font_size: float, alignment: str \| int, read_only: bool, required: bool) → Field | Add a combo box, optionally allowing values outside its option list. |
| add_push_button(name: str, page: Any, rect: Sequence[float], caption: str, read_only: bool, required: bool) → Field | Add a caption-only push button with a generated normal appearance. |
| remove_field(name: str) → Field | Remove a field by fully qualified name and return the removed field. |
| generate_appearances() → int | Regenerate field appearance streams from the current field values. |
| flatten() | Flatten all fields in the form, making them part of the page content. |