diff --git a/src/api/form/PDFForm.ts b/src/api/form/PDFForm.ts index e92c833fc..f9e6ed9b6 100644 --- a/src/api/form/PDFForm.ts +++ b/src/api/form/PDFForm.ts @@ -584,12 +584,14 @@ export default class PDFForm { for (let i = 0, len = widgets.length; i < len; i++) { const widget = widgets[i]; - const widgetRef = this.findWidgetAppearanceRef(field, widget); + const widgetRef = this.doc.context.getObjectRef(widget.dict); const page = this.findWidgetPage(widget); pages.add(page); - page.node.removeAnnot(widgetRef); + if (widgetRef !== undefined) { + page.node.removeAnnot(widgetRef); + } } pages.forEach((page) => page.node.removeAnnot(field.ref));