Filling PDF Forms |
PdfFormManager reads and fills the form fields (AcroForm) of an existing PDF document: text boxes, check boxes, radio button lists, combo boxes and list boxes. The filled form can stay fillable, become read-only, or be flattened into page content.
using ExpertPdf.Anywhere.PDFForms; PdfFormManager form = new PdfFormManager(); form.Load("application.pdf"); FormFieldTextBox name = form.Fields["name"] as FormFieldTextBox; if (name != null) name.Text = "John Smith"; FormFieldCheckBox agree = form.Fields["agree"] as FormFieldCheckBox; if (agree != null) agree.Checked = true; FormFieldComboBox country = form.Fields["country"] as FormFieldComboBox; if (country != null) country.SelectedValue = "Canada"; form.Save("application-filled.pdf"); form.Close();
Fields lists every field, by index or by name (the partial or the full name). Each field has its Name and FullName, the page and rectangle it is shown at, and its widgets when it is shown in several places.
Flatten draws the values into the pages and removes the fields; a field's own Flatten flattens only that field.
ReadOnly keeps the fields but makes them read-only.
Saving appends the changes to the original file (an incremental update), so a signature the document already carries stays valid. Set CompactSave to write a new, smaller file instead.
Text in any script is drawn with a font that has it, from the system or from the ExpertPdf.Anywhere.Fonts package.
Forms made with Adobe LiveCycle Designer that keep their fields only as XFA (no AcroForm fields) cannot be filled; hybrid forms, which have both, are filled through their AcroForm fields.