PdfAcroForm class
Namespace: PdfNetStack
Assembly: PdfNetStack.dll
Package: PdfNetStack
The interactive form of a document (AcroForm, ISO 32000-1, 12.7): its fields, their values, and flattening into plain page content.
public sealed class PdfAcroFormInheritance
Remarks
Section titled “Remarks”Setting a value regenerates the field’s appearance, so the filled form looks right in every viewer without relying on NeedAppearances. Documents that also carry an XFA form lose it when values change, so viewers show the AcroForm values.
Properties
Section titled “Properties”Exists
Section titled “ Exists”True when the document has an interactive form.
public bool Exists { get; }Property Value
Section titled “Property Value”Fields
Section titled “ Fields”Every terminal field, in tree order, with its fully qualified name. Recomputed on each call, so it reflects fields added or removed through the object model.
public IReadOnlyList<PdfField> Fields { get; }Property Value
Section titled “Property Value”NeedAppearances
Section titled “ NeedAppearances”When true, viewers rebuild field appearances themselves. Values set here always come with appearances.
public bool NeedAppearances { get; set; }Property Value
Section titled “Property Value”this[string]
Section titled “ this[string]”The field with this fully qualified name (“address.city”), or null.
public PdfField? this[string name] { get; }Property Value
Section titled “Property Value”Methods
Section titled “Methods”AddCheckBox(PdfPage, string, double, double, double, double, bool, PdfFieldOptions?)
Section titled “ AddCheckBox(PdfPage, string, double, double, double, double, bool, PdfFieldOptions?)”Adds a check box.
public PdfCheckBoxField AddCheckBox(PdfPage page, string name, double x, double y, double width, double height, bool isChecked = false, PdfFieldOptions? options = null)Parameters
Section titled “Parameters”page PdfPage
The page it shows on.
name string
The field name, unique in the form, without dots.
x double
Left edge, from the page’s left.
y double
Top edge, from the page’s top.
width double
Width.
height double
Height.
isChecked bool
Whether it starts checked.
options PdfFieldOptions?
Look and behaviour; defaults when null.
Returns
Section titled “Returns”AddComboBox(PdfPage, string, double, double, double, double, IEnumerable<string>, string?, PdfFieldOptions?)
Section titled “ AddComboBox(PdfPage, string, double, double, double, double, IEnumerable<string>, string?, PdfFieldOptions?)”Adds a drop down list.
public PdfChoiceField AddComboBox(PdfPage page, string name, double x, double y, double width, double height, IEnumerable<string> choices, string? selected = null, PdfFieldOptions? options = null)Parameters
Section titled “Parameters”page PdfPage
The page it shows on.
name string
The field name, unique in the form, without dots.
x double
Left edge, from the page’s left.
y double
Top edge, from the page’s top.
width double
Width.
height double
Height.
choices IEnumerable<string>
The options, as shown and as exported.
selected string?
The option selected at first, or null.
options PdfFieldOptions?
Look and behaviour; defaults when null. Editable allows other text.
Returns
Section titled “Returns”AddListBox(PdfPage, string, double, double, double, double, IEnumerable<string>, IEnumerable<string>?, PdfFieldOptions?)
Section titled “ AddListBox(PdfPage, string, double, double, double, double, IEnumerable<string>, IEnumerable<string>?, PdfFieldOptions?)”Adds a scrolling list.
public PdfChoiceField AddListBox(PdfPage page, string name, double x, double y, double width, double height, IEnumerable<string> choices, IEnumerable<string>? selected = null, PdfFieldOptions? options = null)Parameters
Section titled “Parameters”page PdfPage
The page it shows on.
name string
The field name, unique in the form, without dots.
x double
Left edge, from the page’s left.
y double
Top edge, from the page’s top.
width double
Width.
height double
Height.
choices IEnumerable<string>
The options, as shown and as exported.
selected IEnumerable<string>?
The options selected at first; more than one needs MultiSelect.
options PdfFieldOptions?
Look and behaviour; defaults when null.
Returns
Section titled “Returns”AddPushButton(PdfPage, string, double, double, double, double, string, Uri?, PdfFieldOptions?)
Section titled “ AddPushButton(PdfPage, string, double, double, double, double, string, Uri?, PdfFieldOptions?)”Adds a push button with a caption, opening a web address when pressed if one is given.
public PdfPushButtonField AddPushButton(PdfPage page, string name, double x, double y, double width, double height, string caption, Uri? uri = null, PdfFieldOptions? options = null)Parameters
Section titled “Parameters”page PdfPage
The page it shows on.
name string
The field name, unique in the form, without dots.
x double
Left edge, from the page’s left.
y double
Top edge, from the page’s top.
width double
Width.
height double
Height.
caption string
The text on the button.
uri Uri?
The address it opens, or null for a button scripts or submit actions are attached to later.
options PdfFieldOptions?
Look and behaviour; defaults when null.
Returns
Section titled “Returns”AddRadioGroup(string, IEnumerable<(PdfPage Page, double X, double Y, double Width, double Height, string Value)>, string?, PdfFieldOptions?)
Section titled “ AddRadioGroup(string, IEnumerable<(PdfPage Page, double X, double Y, double Width, double Height, string Value)>, string?, PdfFieldOptions?)”Adds a group of radio buttons sharing one value: selecting one clears the others.
public PdfRadioButtonField AddRadioGroup(string name, IEnumerable<(PdfPage Page, double X, double Y, double Width, double Height, string Value)> buttons, string? selected = null, PdfFieldOptions? options = null)Parameters
Section titled “Parameters”name string
The field name, unique in the form, without dots.
buttons IEnumerable<(PdfPage Page, double X, double Y, double Width, double Height, string Value)>
Each button: its page, its box (from the page’s top left) and the value it stands for.
selected string?
The value selected at first, or null.
options PdfFieldOptions?
Look and behaviour; defaults when null.
Returns
Section titled “Returns”Exceptions
Section titled “Exceptions”There are no buttons, or two share a value.
AddSignatureField(PdfPage, string, double, double, double, double, PdfFieldOptions?)
Section titled “ AddSignatureField(PdfPage, string, double, double, double, double, PdfFieldOptions?)”Adds an empty signature field, to be signed later by this library or a viewer.
public PdfSignatureField AddSignatureField(PdfPage page, string name, double x, double y, double width, double height, PdfFieldOptions? options = null)Parameters
Section titled “Parameters”page PdfPage
The page it shows on.
name string
The field name, unique in the form, without dots.
x double
Left edge, from the page’s left.
y double
Top edge, from the page’s top.
width double
Width.
height double
Height.
options PdfFieldOptions?
Look and behaviour; defaults when null.
Returns
Section titled “Returns”AddTextField(PdfPage, string, double, double, double, double, string?, PdfFieldOptions?)
Section titled “ AddTextField(PdfPage, string, double, double, double, double, string?, PdfFieldOptions?)”Adds a text box. Positions are in points from the page’s top left corner, as for drawing.
public PdfTextField AddTextField(PdfPage page, string name, double x, double y, double width, double height, string? value = null, PdfFieldOptions? options = null)Parameters
Section titled “Parameters”page PdfPage
The page it shows on.
name string
The field name, unique in the form, without dots.
x double
Left edge.
y double
Top edge.
width double
Width.
height double
Height.
value string?
The initial text, or null.
options PdfFieldOptions?
Look and behaviour; defaults when null.
Returns
Section titled “Returns”Examples
Section titled “Examples”PdfTextField name = doc.Form.AddTextField(page, "name", 72, 100, 200, 20);
doc.Form.AddCheckBox(page, "subscribe", 72, 130, 14, 14, isChecked: true);
doc.Form.AddComboBox(page, "country", 72, 160, 150, 20, ["Belgium", "France", "Morocco"], "France");
Flatten()
Section titled “ Flatten()”Draws every field’s current appearance into its page and removes the form: the values stay visible and printable but can no longer be edited. Hidden fields are dropped.
public void Flatten()