PdfFormFieldCollection
Represents a collection of form fields in a PDF document. Provides access to the top-level form fields in the document’s AcroForm.
using Nutrient;The SDK creates this class through factory methods or other SDK objects.
Collection access
PdfFormFieldCollection implements IReadOnlyList<PdfFormField>, so you can index it, read its Count, and iterate it with foreach.
public PdfFormField this[int index] { get; }Gets the element at the specified 0-based index. Type: PdfFormField
Properties
Count
public int Count { get; }The number of top-level form fields in the document.
Type: int
Methods
AddCheckBoxField
public PdfCheckBoxField AddCheckBoxField(string name, PdfPage page, float x, float y, float width, float height)Adds a new check box field to the document on the specified page.
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the check box field. Must be unique within the document. |
page | PdfPage | The page where the check box field will be placed. |
x | float | The x coordinate of the field’s origin in points. |
y | float | The y coordinate of the field’s origin in points. |
width | float | The width of the field in points. |
height | float | The height of the field in points. |
Returns: PdfCheckBoxField - The newly created PdfCheckBoxField. Throws: NutrientException - Thrown when no document is loaded.
Throws: NutrientException - Thrown when the field creation fails.
AddComboBoxField
public PdfComboBoxField AddComboBoxField(string name, PdfPage page, float x, float y, float width, float height)Adds a new combo box (drop-down list) field to the document on the specified page.
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the combo box field. Must be unique within the document. |
page | PdfPage | The page where the combo box field will be placed. |
x | float | The x coordinate of the field’s origin in points. |
y | float | The y coordinate of the field’s origin in points. |
width | float | The width of the field in points. |
height | float | The height of the field in points. |
Returns: PdfComboBoxField - The newly created PdfComboBoxField. Throws: NutrientException - Thrown when no document is loaded.
Throws: NutrientException - Thrown when the field creation fails.
AddListBoxField
public PdfListBoxField AddListBoxField(string name, PdfPage page, float x, float y, float width, float height)Adds a new list box field to the document on the specified page.
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the list box field. Must be unique within the document. |
page | PdfPage | The page where the list box field will be placed. |
x | float | The x coordinate of the field’s origin in points. |
y | float | The y coordinate of the field’s origin in points. |
width | float | The width of the field in points. |
height | float | The height of the field in points. |
Returns: PdfListBoxField - The newly created PdfListBoxField. Throws: NutrientException - Thrown when no document is loaded.
Throws: NutrientException - Thrown when the field creation fails.
AddPushButtonField
public PdfPushButtonField AddPushButtonField(string name, PdfPage page, float x, float y, float width, float height)Adds a new push button field to the document on the specified page.
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the push button field. Must be unique within the document. |
page | PdfPage | The page where the push button field will be placed. |
x | float | The x coordinate of the field’s origin in points. |
y | float | The y coordinate of the field’s origin in points. |
width | float | The width of the field in points. |
height | float | The height of the field in points. |
Returns: PdfPushButtonField - The newly created PdfPushButtonField. Throws: NutrientException - Thrown when no document is loaded.
Throws: NutrientException - Thrown when the field creation fails.
AddRadioButtonField
public PdfRadioButtonField AddRadioButtonField(string groupName, string optionName, PdfPage page, float x, float y, float width, float height)Adds a new radio button to an existing or new radio button group on the specified page.
Parameters
| Name | Type | Description |
|---|---|---|
groupName | string | The name of the radio button group. All radio buttons with the same group name are mutually exclusive. |
optionName | string | The unique option name for this radio button within the group. |
page | PdfPage | The page where the radio button will be placed. |
x | float | The x coordinate of the field’s origin in points. |
y | float | The y coordinate of the field’s origin in points. |
width | float | The width of the field in points. |
height | float | The height of the field in points. |
Returns: PdfRadioButtonField - The PdfRadioButtonField representing the radio button group. Throws: NutrientException - Thrown when no document is loaded.
Throws: NutrientException - Thrown when the field creation fails.
AddSignatureField
public PdfSignatureField AddSignatureField(string name, PdfPage page, float x, float y, float width, float height)Adds a new signature field to the document on the specified page.
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the signature field. Must be unique within the document. |
page | PdfPage | The page where the signature field will be placed. |
x | float | The x coordinate of the field’s origin in points. |
y | float | The y coordinate of the field’s origin in points. |
width | float | The width of the field in points. |
height | float | The height of the field in points. |
Returns: PdfSignatureField - The newly created PdfSignatureField. Throws: NutrientException - Thrown when no document is loaded.
Throws: NutrientException - Thrown when the field creation fails.
AddTextField
public PdfTextField AddTextField(string name, PdfPage page, float x, float y, float width, float height)Adds a new text field to the document on the specified page.
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the text field. Must be unique within the document. |
page | PdfPage | The page where the text field will be placed. |
x | float | The x coordinate of the field’s origin in points. |
y | float | The y coordinate of the field’s origin in points. |
width | float | The width of the field in points. |
height | float | The height of the field in points. |
Returns: PdfTextField - The newly created PdfTextField. Throws: NutrientException - Thrown when no document is loaded.
Throws: NutrientException - Thrown when the field creation fails.
Clear
public void Clear()Removes all form fields from the document.
Throws: NutrientException - Thrown when no document is loaded.
Throws: NutrientException - Thrown when the operation fails.
FindByFullName
public PdfFormField? FindByFullName(string fullName)Finds a form field by its full name (dot-separated path).
Parameters
| Name | Type | Description |
|---|---|---|
fullName | string | The fully qualified name of the field. |
Returns: PdfFormField or null - The PdfFormField if found, null otherwise.
RemoveAt
public void RemoveAt(int index)Removes the form field at the specified index. This also removes any child fields and associated widget annotations.
Parameters
| Name | Type | Description |
|---|---|---|
index | int | The 0-based index of the field to remove. |
Throws: NutrientException - Thrown when index is out of range.
Throws: NutrientException - Thrown when the operation fails.
Resource management
public void Dispose()PdfFormFieldCollection 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.