Section:

Remove PDF form fields

A form field can be removed by deleting its widget annotations. This will remove the ability to interact with the form field since widget annotations represent the appearances of form fields in a PDF document.

Its important to note that a form field can be associated to multiple widget annotations which means there can be multiple interactive appearances and locations in a document for a single form field.

Remove all fields

To remove all form fields in a document, you can remove all widget annotations.

1// config.js
2const { documentViewer, annotationManager, Annotations } = instance.Core;
3
4documentViewer.addEventListener('annotationsLoaded', () => {
5 const annots = annotationManager.getAnnotationsList();
6
7 // find the widget annotations
8 const widgetAnnots = annots.filter(a => a instanceof Annotations.WidgetAnnotation)
9
10 // remove the widget annotations
11 annotationManager.deleteAnnotations(widgetAnnots);
12});

Remove fields by name

To remove a single field, you can find a field by its name and then delete its widget annotations.

1// config.js
2const { documentViewer, annotationManager } = instance.Core;
3
4documentViewer.addEventListener('annotationsLoaded', () => {
5 const fieldManager = annotationManager.getFieldManager();
6 const field = fieldManager.getField('fieldName');
7 annotationManager.deleteAnnotations(field.widgets);
8});

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales