Fill PDF Form Fields Programmatically in React Native
PSPDFKit for React Native allows you to fill form fields programmatically. Each form field has a fully qualified name used to identify and retrieve a specific form field object before filling it.
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 on the first page of a document:
let annotations = await this.refs.pdfView.getAnnotations(0, 'all'); let firstFormFieldName = annotations[0]['formFieldName'];
Filling the Value of a Form Field
The example below shows how to fill the value of a form field with a fully qualified name (formFieldName
) and two radio buttons with fully qualified names (radioFieldName_0
and radioFieldName_1
):
this.refs.pdfView.setFormFieldValue( 'formFieldName', 'Form Field Value', ); // For radio buttons and checkboxes, use `selected` and `deselected`. this.refs.pdfView.setFormFieldValue('radioFieldName_0', 'selected'); this.refs.pdfView.setFormFieldValue('radioFieldName_1', 'deselected');
For more details and sample code, see the ProgrammaticFormFilling.js
example from the Catalog example project.