Skip to Content
GuidesHTML to PDF

HTML to PDF

Client call (via BFF)

const response = await fetch('/api/html-to-pdf', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ html: documentHtml, filename: 'invoice.pdf', disposition: 'attachment', orientation: 'portrait', }), }); const blob = await response.blob();

Inline PDF (restricted)

disposition: 'inline' is allowed only when the request passes host allowlist checks (dev hosts). Configure via handler options in advanced deployments.

Concurrency

Rendering uses a slot semaphore (HTML_TO_PDF_MAX_CONCURRENT). Heavy load: scale horizontally or lower concurrency per instance.

Troubleshooting

IssueCheck
500 on serverChromium missing in Docker
Empty PDFHTML must be complete document or valid fragment for Puppeteer
Build error on routeExport config inline in pages/api/html-to-pdf/index.ts

See @sumx/ssr-pdf.