Extract data from PDF form fields in React Native
Nutrient React Native SDK allows you to extract data from form fields programmatically. Each form field has a fully qualified name, which is used to identify and retrieve a specific form field object before extracting its data.
Getting the fully qualified name of a form field
The example below shows how to obtain the fully qualified name of the first form field of a document:
const formElements = await this.pdfRef.current?.getDocument().forms.getFormElements();const firstFormFieldName = formElements[0].fullyQualifiedFieldName;The getFormElements method returns an array of FormElement objects. See the API reference for a list of available objects.
Getting the data from a form field
The example below shows how to get the value of a form field with a fullyQualifiedFieldName of Last_Name:
const formElements = await this.pdfRef.current ?.getDocument() .forms.getFormElements();const formElement = formElements?.find( (element) => element.fullyQualifiedFieldName === 'Last_Name',);const lastName = formElement?.formField?.value;