Read-only forms

You may sometimes want to restrict editing to all or only a few selected form fields. You can do so by setting a form field’s readOnly property to true:

// Retrieve all form fields from the document.
const formFields = await instance.getFormFields();
// Set the `readOnly` flag on each form field.
const updatedFormFields = formFields.map((it) =>
it.set("readOnly", true)
);
// Update the form fields.
await instance.update(updatedFormFields);

If you don’t have the Form Creator license, you can’t change the behavior of actual form fields. In that case, you can apply client-side restrictions to make the form fields read-only using isEditableAnnotation:

PSPDFKit.load({
// ... Other options.
isEditableAnnotation: function (ann) {
return !(ann instanceof PSPDFKit.Annotations.WidgetAnnotation);
}
});

If you want to do this after PSPDFKit has loaded, you can use instance.setIsEditableAnnotation instead.

This has been tested with Nutrient Web SDK 2021.1.0.