@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
| Field | Description |
|---|---|
margin | PDF margins (normalized by package) |
landscape | Boolean or "true" / "false" |
disposition | attachment or inline (inline restricted by host allowlist) |
Environment
| Variable | Default | Purpose |
|---|---|---|
HTML_TO_PDF_MAX_CONCURRENT | 2 | Render slot limit (max 8) |
HTML_TO_PDF_DEBUG | off | Verbose server logs |
Docker
Images need Chromium. See Docker (portal image).