From 0057af0b8b01cc550258073f53f7ad310b21b143 Mon Sep 17 00:00:00 2001 From: kleitham Date: Fri, 8 Jul 2022 11:06:40 -0400 Subject: [PATCH] Getting correct widget ref to be removed --- src/api/form/PDFForm.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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));