Playwright HTML → PDF Renderer
Setup (one-time per environment)
npm install playwrightnpx playwright install chromium
The
npx playwright install chromiumstep is bootstrap-only. Do not run it per request.
Runtime (every render request)
- Launch Playwright Chromium headless.
- Load HTML (
file://...orsetContent). - Wait for readiness (
networkidle,document.fonts.ready). - Export with
page.pdf({ printBackground: true, preferCSSPageSize: true }). - Close browser and verify output file exists.
API keys
- Local Playwright/Chromium: no API key required.
- Cloud browser provider: provider API key required.
