Class FormFieldCollection
Observable collection of form fields
Inheritance
Implements
Namespace: IronSoftware
Assembly: IronPdf.dll
Syntax
public class FormFieldCollection : ObservableCollection<IFormField>, IFormFieldCollection, IList<IFormField>, ICollection<IFormField>, IEnumerable<IFormField>, IEnumerable
The fillable form fields on an IronPDF document are reached through FormFieldCollection, the value returned by the read-only PdfDocument.Form property. It is the concrete, observable container of those fields. The interface it implements, IFormFieldCollection, lives in the IronSoftware.Forms subnamespace, so prose that mentions both types must qualify them.
FormFieldCollection matters whenever application code touches fillable PDF forms in IronPDF. Filling an existing form, removing or adding fields on a generated document, flattening forms before distribution, and embedding a document-wide font for non-ASCII fills are all routed through this collection. Because the property PdfDocument.Form returns the concrete FormFieldCollection, downstream code can call collection-level mutators directly without casting from the interface.
The headline surface groups into four buckets. Lookup and iteration: FindFormField(string) returns an IFormField by name (the implementation tries the fully-qualified name first, then falls back to partial matches), and the standard IList<IFormField> indexer plus IEnumerable<IFormField> iteration are inherited from the ObservableCollection<IFormField> base. Mutation: Add(IFormField), Remove(IFormField), RemoveAt(int), and Clear() operate on the field set. Font control: SetFormFont(string fontName, byte[] fontData, bool forceEmbed = false) registers a document-wide font for subsequent fills, and DisableFormFontFallback() suppresses the automatic fallback embed for non-ASCII values without registering any replacement font. State: the read-only IsReadOnly property reports whether the collection is mutable. The canonical idiom for fills is documented in the fill and edit PDF forms how-to.
using IronPdf;
using IronSoftware.Forms;
PdfDocument pdf = PdfDocument.FromFile("application.pdf");
// PdfDocument.Form returns the concrete FormFieldCollection.
FormFieldCollection fields = pdf.Form;
// Lookup is by name; fully-qualified matches win, partial matches fall back.
IFormField nameField = fields.FindFormField("applicant.fullName");
nameField.Value = "Jane Doe";
// Optional: register a document-wide font so non-ASCII fills are not
// auto-embedded with a fallback face.
// fields.SetFormFont("Helvetica", File.ReadAllBytes("Helvetica.ttf"));
// Collection-level mutators are inherited from ObservableCollection<IFormField>.
IFormField stale = fields.FindFormField("legacyConsent");
if (stale != null) fields.Remove(stale);
pdf.SaveAs("application-filled.pdf");For building forms from scratch through HTML or programmatic construction, see the create PDF forms how-to. For the field-level contract returned by FindFormField, see IFormField.
Properties
IsReadOnly
Declaration
public bool IsReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
Add(IFormField)
Declaration
public void Add(IFormField item)
Parameters
| Type | Name | Description |
|---|---|---|
| IFormField | item |
Clear()
Declaration
public void Clear()
DisableFormFontFallback()
Suppresses the automatic font fallback embed for non-ASCII form values without registering any replacement font. Zero bytes are added to the document.
Declaration
public void DisableFormFontFallback()
FindFormField(String)
Find a form field with the specified name. First tries to match a fully-qualified name. If a fully-qualified match cannot be found, then partial name matches are tried.
Declaration
public IFormField FindFormField(string Name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | Name | Form field name |
Returns
| Type | Description |
|---|---|
| IFormField | Form field with the specified name |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 |
Remove(IFormField)
Declaration
public bool Remove(IFormField item)
Parameters
| Type | Name | Description |
|---|---|---|
| IFormField | item |
Returns
| Type | Description |
|---|---|
| System.Boolean |
RemoveAt(Int32)
Declaration
public void RemoveAt(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index |
SetFormFont(String, Byte[], Boolean)
Sets the document-wide font for subsequent form field fills on this document. When set, the engine skips the automatic font fallback embed for form values that contain non-ASCII characters.
Declaration
public void SetFormFont(string fontName, byte[] fontData, bool forceEmbed = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | fontName | PDF font name as it appears in the document's /DR /Font dictionary |
| System.Byte[] | fontData | Raw TrueType/OpenType bytes; pass null or empty for name-only mode (the font must already be embedded in the document) |
| System.Boolean | forceEmbed | When true, embed |