ADR-017: Adopt Server-Side Vector PDF Export via Headless Chromium


1. Context

Users export technical Markdown documents containing wide GFM tables, syntax-highlighted code blocks, KaTeX equations, and Mermaid SVG diagrams to PDF for design reviews and executive sharing.

Our previous client-side approach (html2canvas + jsPDF) rasterized pages into PNG bitmaps, causing:

  1. Blurry text when zoomed past 150% and non-selectable text (breaking copy/paste and screen readers).
  2. Large file sizes (8–25 MB for a 10-page RFC).
  3. Inconsistent page breaks splitting Mermaid diagrams and table rows in half.

2. Decision

We will render PDFs server-side using a pooled Playwright / Headless Chromium worker calling page.pdf() against a dedicated print stylesheet, with strict concurrency limits and a 30-second timeout per export.


3. Options Comparison Matrix

Criterion Option 1: Headless Chromium (Server) Option 2: html2canvas + jsPDF (Client) Option 3: Typst / Pandoc LaTeX Pipeline Option 4: External PDF SaaS API
Selectable Vector Text Yes (100% native) No (rasterized) Yes (native) Yes
Mermaid + KaTeX Fidelity Identical to browser Identical to browser Requires custom SVG pre-pass Identical to browser
Typical 10-Page File Size 180 KB – 450 KB 12 MB – 24 MB 120 KB – 300 KB 200 KB – 500 KB
Pagination Control Good (break-inside: avoid) Poor Excellent Good
Infra & Maintenance Cost Low (~$25/mo worker) $0 Medium (custom templates) High ($0.02–$0.05 / export)
Data Privacy Stays in our VPC Stays on device Stays in our VPC Leaves VPC to 3rd party

4. Consequences

Positive

Negative & Mitigations


5. Follow-Up Tasks