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:
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.
| 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 |
mdv export), and MCP server resource.429 export_busy with Retry-After when saturated.route.abort() for non-localhost/non-data URLs) and disabling JavaScript execution for user HTML.npm run check:pdf-quality)break-inside: avoid on .mermaid-wrap, pre, and blockquote