The PDF Viewer library allows you to focus to the respective form field using the focusFormField()
API.
The following steps are used to focus to the respective form field.
Step 1: Follow the steps provided in the link to create a simple PDF Viewer sample.
Step 2: Use the following code sample to focus to the respective form field while loading as well as in a button click.
<button id="focusFormField">FocusFormField</button>
//Event triggers while clicking the FocusFormField button.
document.getElementById('click').addEventListener('click', function () {
var formField = viewer.retrieveFormFields();
//API to bring the form fields in focus.
viewer.focusFormField(formField[1]);
});
//Event triggers while loading the document.
viewer.documentLoad = (args) => {
var formField = viewer.retrieveFormFields();
//API to bring the form fields in focus.
viewer.focusFormField(formField[1]);
};