Fast and reliable end-to-end testing for modern web apps
open sourceApache-2.0self-hostablefreeMCP
Playwright is Microsoft's browser automation and end-to-end testing framework for Chromium, Firefox and WebKit, with APIs for Node.js/TypeScript, Python, Java and .NET. Its page.pdf() method renders a page to PDF using print CSS media, with options for paper format, margins, header and footer templates, tagged (accessible) PDFs and an embedded outline. PDF generation works only in headless Chromium: the call throws 'PDF generation is only supported for Headless Chromium' in Firefox and WebKit. That makes it a common way to print HTML to PDF from Python, Java or C# as well as Node.
Problems it solves
- I need Chrome-quality HTML to PDF from a Python backend, not Node
- print a page to PDF from a .NET or Java service using a real browser engine
- we already run browser tests in CI and want to reuse that setup to export report PDFs
- make an accessible tagged PDF with bookmarks from an HTML page
- render a templated HTML page in headless Chromium and save it as A4 with custom margins
- add a header and footer with the page number and total pages to a PDF printed from HTML
- generate PDFs of pages that need JavaScript to finish rendering before printing
- export the 'screen' version of a page to PDF instead of the print stylesheet
- one browser automation API for screenshots, PDFs and end-to-end tests across languages
- my PDF export works locally but I need it to run in a container on Linux
Features
- page.pdf() in headless Chromium
- paper formats, width/height and margins with units
- header and footer templates with pageNumber and totalPages
- tagged (accessible) PDF option
- document outline option
- emulateMedia to print with screen CSS
- Chromium, Firefox and WebKit automation
- bindings for Node.js, Python, Java and .NET
- Playwright MCP server and CLI for coding agents
Capabilities
| Has a command line tool | plan not known |
|---|---|
| Has an MCP server | plan not known |
| Has official SDKs | plan not known |
Alternatives
The same job
These do what Playwright does.
- WeasyPrint Renders HTML and CSS to PDF, from Python or the command line
- DocRaptor The World's Most Advanced HTML to PDF API
- Cypress AI writes the code. Cypress proves it works.
- Puppeteer JavaScript API for Chrome and Firefox
- PDFShift From HTML to pixel-perfect PDFs in seconds
- Gotenberg A Docker-based API for PDF