MCPcopy Create free account
hub / github.com/LibPDF-js/core / flattenAnnotations

Method flattenAnnotations

src/api/pdf.ts:3005–3022  ·  view source on GitHub ↗

* Flatten all annotations in the document into static page content. * * Annotations are converted to static graphics drawn on each page's content. * After flattening, annotations are removed from the document. * * Annotations without appearances that cannot be generated are removed.

(options?: FlattenAnnotationsOptions)

Source from the content-addressed store, hash-verified

3003 * ```
3004 */
3005 flattenAnnotations(options?: FlattenAnnotationsOptions): number {
3006 const flattener = new AnnotationFlattener(this.ctx.registry);
3007
3008 let totalFlattened = 0;
3009 const pageRefs = this.ctx.pages.getPages();
3010
3011 for (const pageRef of pageRefs) {
3012 const pageDict = this.ctx.resolve(pageRef);
3013
3014 if (!(pageDict instanceof PdfDict)) {
3015 continue;
3016 }
3017
3018 totalFlattened += flattener.flattenPage(pageDict, options);
3019 }
3020
3021 return totalFlattened;
3022 }
3023
3024 /**
3025 * Flatten all interactive content in the document.

Callers 3

flattenAllMethod · 0.95
mainFunction · 0.45

Calls 3

flattenPageMethod · 0.95
getPagesMethod · 0.65
resolveMethod · 0.45

Tested by

no test coverage detected