MCPcopy Create free account
hub / github.com/OpenSignLabs/OpenSign / _removeWidgetAnnotations

Function _removeWidgetAnnotations

apps/OpenSign/src/constant/Utils.js:4187–4221  ·  view source on GitHub ↗

Remove only Widget annotations; preserve links, stamps, comments, etc.

(pdfDoc)

Source from the content-addressed store, hash-verified

4185
4186/** Remove only Widget annotations; preserve links, stamps, comments, etc. */
4187function _removeWidgetAnnotations(pdfDoc) {
4188 for (const page of pdfDoc.getPages()) {
4189 try {
4190 const annotationsRef = page.node.get(PDFName.of("Annots"));
4191 if (!annotationsRef) continue;
4192
4193 const annotations = pdfDoc.context.lookup(annotationsRef);
4194 if (!annotations || !annotations.asArray) continue;
4195
4196 const filtered = annotations.asArray().filter((annotRef) => {
4197 try {
4198 const annot = pdfDoc.context.lookup(annotRef);
4199 const subtype = annot?.get(PDFName.of("Subtype"));
4200 return subtype?.toString() !== "/Widget";
4201 } catch {
4202 return true;
4203 }
4204 });
4205
4206 if (filtered.length === 0) {
4207 page.node.delete(PDFName.of("Annots"));
4208 } else {
4209 page.node.set(PDFName.of("Annots"), pdfDoc.context.obj(filtered));
4210 }
4211 } catch {
4212 /* best effort */
4213 }
4214 }
4215
4216 try {
4217 pdfDoc.catalog.delete(PDFName.of("AcroForm"));
4218 } catch {
4219 /* best effort */
4220 }
4221}
4222
4223export const mailTemplate = (param) => {
4224 const appName = "OpenSign™";

Callers 1

flattenPdfFunction · 0.85

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected