* 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)
| 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. |
no test coverage detected