How it works
You write templates using<Document> and <Page> components. Pdfn takes care of the rest:
Key concepts
- Automatic pagination — content flows across pages. No manual
page-breakCSS. - Repeating headers and footers — defined as React components with
<PageNumber>and<TotalPages>. - Same output everywhere — your template produces identical PDFs locally and in production.
- Dev preview —
npx pdfn devgives you live preview with hot reload. Edit a template, see the PDF update.
How templates become PDFs
- Local development —
npx pdfn devruns a preview server with embedded Puppeteer. No setup needed. - Production —
client.generate()sends the template to pdfn Cloud and returns a PDF buffer. SetPDFN_API_KEYand deploy. - Self-hosted —
client.render()gives you HTML. Pass it to your own Puppeteer or Playwright setup.
Get started
Quickstart
Install, create a template, and generate your first PDF
Dev Workflow
Live preview with hot reload
Explore the docs
Components
Document, Page, and layout components
Generate & Render
Client setup, generate() and render() parameters
Styling
Tailwind CSS, custom CSS, and inline styles
Next.js
API routes, download buttons, and edge runtime
Migrate from Puppeteer
Switch from raw Puppeteer to pdfn
Self-Hosting
Run PDF generation on your own infrastructure