* Flatten all interactive content in the document. * * This is a convenience method that flattens: * - Layers (OCGs) - prevents hidden content attacks * - Form fields - converts to static text/graphics * - Annotations - bakes appearances into page content * * Use this before sig
(options?: FlattenAllOptions)
| 3044 | * ``` |
| 3045 | */ |
| 3046 | flattenAll(options?: FlattenAllOptions): FlattenAllResult { |
| 3047 | // Flatten layers first (affects visibility of everything) |
| 3048 | const layerResult = this.flattenLayers(); |
| 3049 | |
| 3050 | // Flatten form fields |
| 3051 | const form = this.getForm(); |
| 3052 | let formFields = 0; |
| 3053 | |
| 3054 | if (form) { |
| 3055 | formFields = form.getFields().length; |
| 3056 | form.flatten(options?.form); |
| 3057 | } |
| 3058 | |
| 3059 | // Flatten annotations last (may reference form widgets which are now gone) |
| 3060 | // By default, remove Link annotations since they contain actions that |
| 3061 | // Adobe considers "hidden behavior" which can cause signature validation warnings. |
| 3062 | const annotationOptions = { |
| 3063 | removeLinks: true, |
| 3064 | ...options?.annotations, |
| 3065 | }; |
| 3066 | |
| 3067 | const annotations = this.flattenAnnotations(annotationOptions); |
| 3068 | |
| 3069 | return { |
| 3070 | layers: layerResult.layerCount, |
| 3071 | formFields, |
| 3072 | annotations, |
| 3073 | }; |
| 3074 | } |
| 3075 | |
| 3076 | // ───────────────────────────────────────────────────────────────────────────── |
| 3077 | // Text Extraction |
no test coverage detected