Read PDF Form Fields Using JavaScript
Reading all form field objects can be done by using the Instance#getFormFields
API. This API is asynchronous and will return a promise that resolves to an immutable list of FormField
elements and contains their current values. Every FormField
has a unique name
property. In the PDF spec, this is often referred to as the fully qualified name (FQN). This name is similar to an input element’s name
attribute in an HTML form and is used to associate the filled-out value with the form field:
const formFields = await instance.getFormFields(); console.log(formFields.size);
Form fields are rendered following the properties of their associated widget annotation(s), which are listed by id
in the form field’s annotationIds
property. Widget annotations behave like regular annotations and can be loaded via the regular annotations API.