Skip to main content
Already using Puppeteer to generate PDFs? Here’s how to switch to pdfn.

Why migrate

Puppeteer gives you low-level browser control, but you end up managing a lot yourself:
  • Installing and updating Chromium binaries (250MB+)
  • Launching, reusing, and closing browser instances
  • Writing and managing print-related CSS for pagination
  • Working around Puppeteer’s limited header/footer API
  • Debugging layout differences between local and production Chromium versions

Step 1: Install

Add @pdfn/tailwind for Tailwind CSS support, and @pdfn/next for Next.js. See the Quickstart for details.

Step 2: Convert your templates

Replace HTML strings with React components using <Document> and <Page>:
Page size, margins, headers, and footers are declared in the template — no more passing options to page.pdf() or writing @page CSS.

Step 3: Replace the generation code

No browser to launch, no page lifecycle to manage.

Step 4: Remove Puppeteer

If you prefer to keep running your own Chromium, use client.render() instead of client.generate(). See Self-Hosting.

Next steps

Components

Document, Page, and layout components

Styling

Tailwind CSS, custom CSS, and inline styles

Self-Hosting

Run PDF generation on your own infrastructure