pdf_flatten
Flatten PDF — Flatten PDF forms and annotations into static page content. Supports granular modes (annotations-only, forms-only, all), page ranges, signature-aware handling, link preservation, watermark stamping, image compression, PDF/A archival output, OCR for scanned inputs, and a ZIP bundle that exports form values + annotation metadata alongside the flattened file. [category: pdf]
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Input PDF | |
| mode | No | Which interactive elements to flatten. 'none' runs no flatten (useful for OCR/watermark/PDFA-only pipelines). | all |
| pages | No | Optional page range (e.g. '1-3,5,7-9'). Only listed pages are flattened; others stay interactive. | |
| ocrLang | No | Allowlist: eng fra spa deu ita por nld pol chi_sim jpn kor ara rus hin; unknown → eng. Read only when ocrFirst=true (paid OCR tier). | eng |
| ocrFirst | No | Run ocrmypdf before flattening (for scanned PDFs). Requires Starter+ tier. | |
| exportData | No | Return a ZIP containing the flattened PDF plus form_values.json and annotations.json side files. | |
| outputFormat | No | pdfa produces a PDF/A-2b archival output. Requires Starter+ tier. | |
| preserveLinks | No | Keep clickable hyperlinks after flattening (uses qpdf --flatten-annotations=print). | |
| signatureMode | No | preserve = return original when signatures detected; ignore = flatten anyway (invalidates sigs); block = 409 error. | preserve |
| watermarkFont | No | Exactly Helvetica, Times-Roman, or Courier (case-sensitive); anything else becomes Helvetica. Read only when watermarkText is set. | Helvetica |
| watermarkText | No | Text watermark to stamp before flattening. Leave empty to skip. | |
| watermarkTile | No | NOT available here — true returns a clear error (the flatten tile path is broken in the pinned engine; run pdf_watermark, which tiles, before flattening). | |
| compressImages | No | Downsample images after flattening to shrink file size. | |
| compressPreset | No | screen|ebook|printer|prepress (Ghostscript). Read only when compressImages=true; unknown → ebook. screen=72dpi, printer/prepress=300dpi. | ebook |
| outputFilename | No | Optional custom filename for the flattened output (without path). | |
| watermarkColor | No | Hex color, #rgb or #rrggbb. | #808080 |
| watermarkScale | No | Absolute scale factor; default 1.0. Non-numeric resets to 1.0. | |
| watermarkOpacity | No | 0 = invisible, 1 = solid; default 0.3. Non-numeric resets to 0.3. Read only when watermarkText is set. | |
| watermarkFontSize | No | Point size, integer; non-integer input silently resets to 48. Read only when watermarkText is set. | |
| watermarkPosition | No | pdfcpu anchor: c tl tc tr ml mr bl bc br (ml/mr are folded to the engine's l/r); unknown → c (center). Read only when watermarkText is set. | c |
| watermarkRotation | No | Degrees, integer; default 45 = classic diagonal. Non-integer resets to 45. Read only when watermarkText is set. |