Skip to Content
Packages@sumx/ssr-pdf

@sumx/ssr-pdf

Puppeteer-based POST /api/html-to-pdf for Next.js Pages Router.

API route (portal)

Next.js requires config inline in the route file (cannot re-export):

// src/pages/api/html-to-pdf/index.ts export { default } from '@sumx/ssr-pdf/next/html-to-pdf-handler'; export const config = { api: { bodyParser: { sizeLimit: '5mb' }, responseLimit: false, }, };

Keep in sync with htmlToPdfApiRouteConfig in the package.

Request body (basic)

{ "html": "<html><body><h1>Report</h1></body></html>", "filename": "report.pdf", "disposition": "attachment", "orientation": "portrait" }

Advanced options

FieldDescription
marginPDF margins (normalized by package)
landscapeBoolean or "true" / "false"
dispositionattachment or inline (inline restricted by host allowlist)

Environment

VariableDefaultPurpose
HTML_TO_PDF_MAX_CONCURRENT2Render slot limit (max 8)
HTML_TO_PDF_DEBUGoffVerbose server logs

Docker

Images need Chromium. See Docker (portal image).