PDF form basics ​
This topic introduces PDF form concepts and shows how to perform basic form operations with the APIs provided by Foxit PDF SDK for Web.
Introduction to PDF forms ​
A PDF form is a special type of PDF document that contains interactive fields where users can enter text or select checkboxes. You can create PDF forms from any PDF, word processor, image file, or paper document.
In Foxit PDF SDK for Web, PDF forms are organized into three object types by structure: Form, Field, and Widget, corresponding to the form, fields, and field widgets in the PDF document.
Form: class name
PDFForm; obtain an instance with PDFDoc.getForm().Field: class name
PDFFormField; obtain instances with PDFForm.getField and PDFForm.getFieldAtPosition.Widget: class name
Widget; obtain instances with PDFFormField.getWidgetsCount and PDFFormField.getWidget. Note that Widget is a special type of annotation (Annot) and can also be obtained throughPDFPagegetAnnots, filtered by type.
Signature fields are a special field type with a dedicated class PDFSignature. PDFSignature extends PDFFormField and adds signature-related APIs.
The following diagram shows how these objects relate:
mermaid
classDiagram
class PDFDoc
class PDFForm
class PDFPage
class PDFFormField
class Widget
PDFDoc --> PDFForm : has a
PDFDoc --> PDFPage : has many
PDFForm --> PDFFormField : has many
PDFFormField --> Widget : has many
PDFPage --> Widget : has many
class PDFDoc {
+getPDFForm(): PDFForm;
+getPageByIndex(pageIndex): Promise<PDFPage>;
}
class PDFForm {
+getField(fieldName): Promise<PDFFormField>;
+getFields(): Promise<PDFFormField>;
}
class PDFPage {
+getAnnots(): Promise<Annot>;
}
class PDFFormField {
+getWidgetsCount(): number;
+getWidget(index): number;
}Form features in Foxit PDF SDK for Web ​
You can use the APIs provided by Foxit PDF SDK for Web to:
- Add or remove form fields
- Get or set form field properties
- Import and export form data
- Add and edit form actions
You can also extend form behavior with Actions, for example:
- Develop JavaScript scripts for custom operations on user events
- Automatically format, calculate, and validate form data
- Integrate with web services
These capabilities give developers strong tools for building complex, interactive PDF form applications—for online surveys, application forms, order forms, and more.