Skip to main content
PDF generation requires the pdf capability. Start the server with --caps=pdf to enable this tool.
Playwright MCP provides PDF generation capabilities, allowing you to save web pages as PDF documents. This is useful for creating reports, archiving web content, or generating printable versions of web pages.

Enabling PDF Capability

To use PDF generation tools, start the MCP server with the pdf capability:
You can combine it with other capabilities:

browser_pdf_save

Save the current page as a PDF document.
string
File name to save the PDF to. Defaults to page-{timestamp}.pdf if not specified. Prefer relative file names to stay within the output directory.
Read-only: Yes

Use Cases

Generate Reports

Create PDF reports from web dashboards or analytics pages:

Archive Web Content

Preserve web content as PDF for archival purposes:

Batch PDF Generation

Generate multiple PDFs from different pages:

Create Printable Versions

Generate printer-friendly PDFs of web content:

PDF Formatting Tips

Always wait for dynamic content to fully load before generating PDFs. Use browser_wait_for with appropriate time or text conditions.
The PDF will reflect the current browser viewport size. Use browser_resize to set an appropriate width for PDF generation:
Many websites have special CSS for printing. The PDF will use these print stylesheets if they exist, which may differ from the on-screen view.
Some pages use lazy loading for images. Scroll through the page before generating the PDF to ensure all images are loaded:

File Naming

When specifying filenames for PDFs:
  • Relative paths: Preferred. Will be saved in the output directory.
  • Absolute paths: Also supported, but relative paths are recommended.
  • Default naming: If no filename is provided, a timestamped name is used.
Use descriptive filenames that indicate the content and date, e.g., analytics-report-2024-03.pdf

Combining with Other Tools

PDF generation works well with other Playwright MCP tools:

Common Issues

If you get an error about PDF capability not being enabled, make sure you started the server with --caps=pdf.
If content is missing from the PDF:
  • Wait longer for dynamic content to load
  • Scroll through the page to trigger lazy-loaded elements
  • Check if the page uses JavaScript to render content
If the PDF layout looks wrong:
  • Adjust the browser viewport size with browser_resize
  • Check if the site has print-specific CSS that affects layout
  • Some interactive elements may not render well in PDF
If the PDF file isn’t where you expect:
  • Use relative paths to save in the output directory
  • Check the tool response for the actual save location
  • Verify you have write permissions to the target directory

Take Screenshot

Capture page as image instead of PDF

Browser Resize

Adjust viewport size for optimal PDF layout

Wait For

Wait for content to load before generating PDF