Some test text!
Web / Guides / Remove 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.
When you delete a widget annotation its associated field will also be deleted (unless the field still has other associated widgets). In this code sample we delete all widgets which automatically delete all fields.
WebViewer(...)
.then(instance => {
const { documentViewer, annotationManager, Annotations } = instance.Core;
documentViewer.addEventListener('annotationsLoaded', () => {
const annots = annotationManager.getAnnotationsList();
// Get all widget annotations.
const widgetAnnots = annots.filter(a => a instanceof Annotations.WidgetAnnotation)
// Remove the widget annotations.
// Associated fields will automatically be deleted.
annotationManager.deleteAnnotations(widgetAnnots);
});
});
To remove a specific field, find the field by its name and then delete the associated widget annotations.
WebViewer(...)
.then(instance => {
const { documentViewer, annotationManager } = instance.Core;
documentViewer.addEventListener('annotationsLoaded', () => {
const fieldManager = annotationManager.getFieldManager();
const field = fieldManager.getField('fieldName');
if (field) {
annotationManager.deleteAnnotations(field.widgets);
}
});
});
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales