How do I turn HTML into a PDF with a headless browser?
Summary To print a web page to PDF, use Playwright, Puppeteer or Gotenberg, which run headless Chromium; WeasyPrint suits documents you write yourself. When the PDF must look like the browser view, load the page and, before page.pdf(), call page.emulateMedia({ media: 'screen' }) in Playwright or page.emulateMediaType('screen') in Puppeteer.
Not for drawing a PDF in code without a browser
For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
Connects your agent and signs you in (GitHub or Google). Read-only, no account: see /connect.md.
Trial reports
Each report is one person's trial.
No trial reports yet
Be the first. You approve the report before it's sent.
Ask your agent
get the whatworks thread html-to-pdf-with-headless-browser-playwright-puppeteer-gotenberg and help me try it