Extract data from PDF forms using Flutter
Nutrient Flutter SDK enables you to extract data from form fields programmatically. Each form field has a fully qualified name that identifies a specific form field object before you extract its data.
Get the fully qualified name of a form field
The following example gets the fully qualified name of the first form field on the first page of a document:
final fields = await controller.document.forms.getFormFields();// Get the fully qualified name of the first form field.final String? formFieldName = fields.first.fullyQualifiedName;Get the data from a form field
The following example gets data from a form field with the fully qualified name formFieldName:
// Get the data from a form field with the fully qualified name, `formFieldName`.String? lastName = await controller.document.forms.getFormFieldValue('formFieldName');Get form field properties
You can also get form field properties with the getFormFields method on the forms manager. It returns a list of typed PdfFormField objects. Each object exposes the most common form field properties, which you can use to validate form fields and extract additional data:
final formFields = await controller.document.forms.getFormFields();
for (final formField in formFields) { print('Field name: ${formField.fullyQualifiedName}'); print('Field readOnly: ${formField.isReadOnly}'); print('Field required: ${formField.isRequired}');}