Read-only Forms

Q: How can I make form fields read-only?

You could get to a situation where you want to restrict editing to all or only a few selected form fields. You can do so by setting form field’s property readOnly to true:

Copy
1
2
3
4
5
6
7
8
// Retrieve all form fields from the document.
const formFields = await instance.getFormFields();

// Set `readOnly` flag on each form field.
const updatedFormFields = formFields.map(it => it.set('readOnly', true));

// Update the form fields.
await instance.update(updatedFormFields);

This has been tested with PSPDFKit for Web 2020.6.0.