 |
PdfFormManager Class |
Reads and fills the AcroForm fields of an existing PDF document. Load a document with one of
the
Load overloads, read or set values through
Fields, then persist the
changes with
Save(String) /
GetDocument.
Inheritance HierarchySystemObject
SelectPdf.UniversalPdfFormManager
Namespace: SelectPdf.UniversalAssembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.6
Syntaxpublic class PdfFormManager : IDisposable
Public Class PdfFormManager
Implements IDisposable
The PdfFormManager type exposes the following members.
Constructors| | Name | Description |
|---|
 | PdfFormManager |
Initializes a new instance of the PdfFormManager class. Call one of the
Load overloads before accessing Fields.
|
Top
Properties| | Name | Description |
|---|
  | CompactSave |
Gets or sets a value indicating whether the document is rewritten from scratch on save
instead of being updated incrementally. Default is false.
|
 | Fields |
Gets the collection of form fields in the loaded document. A document with no AcroForm -
which is the state a document is in after Flatten and a save - returns an
EMPTY collection, not null, so manager.Fields.Count is always safe to read.
|
 | Flatten |
Gets or sets a value indicating whether the whole form is flattened on save. An XFA form that lays itself
out is saved flattened as the pages it lays out, with the values it holds and no form.
|
 | IsXfaForm |
Gets a value indicating whether the loaded document's form is defined in XFA (a form that lays itself out,
or a hybrid form), whatever XfaMode says.
|
 | ReadOnly |
Gets or sets a value indicating whether the pdf form is read-only or not.
|
 | ScriptErrors |
Gets the errors the form's own scripts failed with (what Acrobat's JavaScript console shows), or why an XFA
form could not be opened as XFA in Auto mode. Empty for an AcroForm.
|
 | ScriptMessages |
Gets the messages the form's own scripts showed, in the order they were shown (an XFA form reports this way
a value its validation refuses, or the result of its own check button). Empty for an AcroForm.
|
  | XfaMode |
Gets or sets how a form defined in XFA is filled: as XFA, or through its AcroForm fields. Default is
Auto. It applies to the documents loaded after it is set.
|
Top
Methods| | Name | Description |
|---|
 | Click |
Clicks a field of an XFA form that lays itself out: its click scripts run, as in Acrobat. For a button, that
is what the button does (a form's own check, or building the data it attaches); a check box or radio
button is set through its value instead.
|
 | Close | Closes the loaded document and releases its resources. |
 | Dispose |
Releases the loaded document, the same as Close.
Lets the PdfFormManager be used in a using statement.
Calling it after Close, or more than once, does nothing.
|
 | GetDocument |
Serializes the current state and returns it as a new PdfDocument for further
processing (adding pages, merging, applying security, etc.).
|
 | Load(Byte) | Loads a PDF document from a byte array. |
 | Load(PdfDocument) | Loads the AcroForm of an existing PdfDocument. |
 | Load(Stream) | Loads a PDF document from a stream. |
  | Load(String) | Loads a PDF document from a file. |
 | Load(Byte, String) | Loads a password-protected PDF document from a byte array. |
 | Load(PdfDocument, String) | Loads an existing PdfDocument with a password. |
 | Load(Stream, String) | Loads a password-protected PDF document from a stream. |
 | Load(String, String) | Loads a password-protected PDF document from a file. |
 | Save | Saves the document (with any field changes) and returns the bytes. |
 | Save(Stream) | Saves the document (with any field changes) to a stream. |
  | Save(String) | Saves the document (with any field changes) to a file. |
Top
RemarksFonts. A field is drawn in the font the form itself specifies. When that font
cannot encode the value — a form built for Latin text given Greek, Japanese or mathematical
symbols — a font that can is chosen from the ones installed on the machine, so the value is
visible and extractable rather than silently blank. If a character still does not appear,
no installed font covers it: installing one is the fix. The directories searched are
%SystemRoot%\Fonts on Windows, /Library/Fonts and ~/Library/Fonts on
macOS, and /usr/share/fonts, ~/.fonts and ~/.local/share/fonts on Linux.
It must be an outline font. A colour-bitmap face — Apple Color Emoji, Noto Color
Emoji — stores its glyphs as images rather than outlines, so it cannot be embedded in a PDF
and is skipped; a monochrome equivalent such as Noto Emoji works. One value is drawn in one
font, so a value mixing scripts that no single installed font covers keeps only the part that
font has.
ExamplePdfFormManager manager = new PdfFormManager();
manager.Load("form.pdf");
PdfFormFieldTextBox name =
manager.Fields["name"] as PdfFormFieldTextBox;
if (name != null) name.Text = "John Doe";
manager.Save("filled.pdf");
manager.Close();Dim manager As New PdfFormManager()
manager.Load("form.pdf")
Dim name As PdfFormFieldTextBox =
TryCast(manager.Fields("name"), PdfFormFieldTextBox)
If name IsNot Nothing Then name.Text = "John Doe"
manager.Save("filled.pdf")
manager.Close()
See Also