Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallSome links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To save a webpage as a PDF with Playwright, navigate to it with page.goto(), then call page.pdf(). To render HTML you already have, load it with page.setContent() first. The PDF method returns a buffer; add the path option to also save it to a file. Playwright’s documented PDF export is Chromium-only.
What you need before generating a PDF
- A Playwright installation and a Chromium browser. The documented PDF export capability requires Chromium; don’t assume the same
page.pdf()workflow works with Firefox or WebKit. See the Playwright PDF Export documentation. - A URL with a scheme, such as
https://example.com, or the HTML markup you want to render. - A decision about whether the PDF should use print or screen styles, what paper size it should use, and whether it needs backgrounds or selected pages.
The examples below use Playwright’s JavaScript API. The API reference is live documentation checked on September 29, 2026; no package release is pinned here. Confirm any options you use against the documentation for your installed Playwright version. Page API
Save a webpage URL as a PDF
Open a page, navigate to the target, and call page.pdf(). Passing path writes the file; the call still returns the PDF data as a buffer.
Recommended Free Tools
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
const pdfBuffer = await page.pdf({ path: 'page.pdf' });
// pdfBuffer is available if you also need to process or return the PDF.
await browser.close();
})();
For example, the Pages guide demonstrates creating a page and navigating with page.goto(). Playwright Pages guide
#1 Best Overall
- COMPLETE 78-CARD DECK: Eternal Whisper Tarot includes a full set of 78 cards featuring all Major and Minor Arcana, a PDF guidebook to help you interpret readings and deepen your spiritual practice
- VINTAGE GOTHIC AESTHETIC: Rendered in a textured world of ink, parchment, and starlit shadows, each card blends artistic darkness with emotional clarity for a hauntingly beautiful divination experience
- Tarot Cards for Beginners: 22 PCS Major cards and 56 PCS minor cards. Whether you are a beginner learning the Page of Wands or an experienced reader expanding your practice, this deck bridges clarity with elegance.
- 300 Gsm Coated Paper: 2.74" x 4.72" (70 mm x 120 mm), have Sufficient folding endurance, Durable, smooth-finish cards designed for everyday readings, shuffling, and long-term use. Rounded edges for a comfortable feel.are ideal for all readers seeking a beautiful & high-end Tarot Deck.
- SPIRITUAL GROWTH AND DIVINATION: Perfect for personal readings, meditation, or spiritual development, this tarot deck helps you connect with deeper wisdom and navigate life's questions with clarity
Convert supplied HTML to a PDF
Use page.setContent(html) to load markup into the page, then print it. setContent() assigns the markup using document.write()-style behavior. Include the styles and assets your document needs; a fragment of markup may not look like the intended finished document without them.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
const html = `
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
body { font: 16px Arial, sans-serif; margin: 24px; }
h1 { color: #17324d; }
</style>
</head>
<body><h1>Quarterly report</h1><p>Report content goes here.</p></body>
</html>`;
await page.setContent(html);
await page.pdf({ path: 'report.pdf', format: 'A4' });
await browser.close();
})();
There is no single readiness wait that guarantees every site’s fonts, images, charts, or client-rendered content is ready. If your input depends on asynchronous rendering, wait for a signal specific to that page—for example, a report element to appear or an application-specific “render complete” state—before printing. Then inspect the resulting PDF to verify the content and pagination.
Choose print or screen styling
By default, page.pdf() renders using print CSS media. If you want the page’s screen-media styles instead, emulate screen media before calling page.pdf():
await page.emulateMedia({ media: 'screen' });
await page.pdf({ path: 'screen-styled.pdf' });
For exact print colors, the Page API points to the CSS property -webkit-print-color-adjust. Set it in the page’s CSS as appropriate for the elements whose colors should be preserved. Playwright Page API
Rank #2
- Prentice Hall Press
- Ideal for a bookworm
- It's a great choice for a book person
Set paper size, margins, and page range
Use format for a named paper size, or set explicit width and height. When format is present, it takes priority over width and height. The documented default format is Letter; default margins are zero.
| Option | What it controls | Documented behavior |
|---|---|---|
format |
Named paper size | Includes Letter, Legal, Tabloid, Ledger, and ISO sizes A0 through A6. Takes priority over width and height. |
width, height |
Page dimensions | Accept px, in, cm, and mm. A number without a unit is interpreted as pixels. |
margin |
Printable-area margins | Accepts explicit units; defaults to none. |
pageRanges |
Pages to include | For example, 1-5, 8, 11-13. An empty value means all pages. |
scale |
Content scaling | Defaults to 1; allowed range is 0.1 to 2. |
preferCSSPageSize |
Whether CSS @page sets the paper size |
Defaults to false. When false, content is scaled to fit the selected paper size; when true, CSS page size takes priority over width, height, or format. |
For example, an A4 PDF with margins and a selected range can be generated like this:
await page.pdf({
path: 'selected-pages.pdf',
format: 'A4',
margin: { top: '12mm', right: '12mm', bottom: '12mm', left: '12mm' },
pageRanges: '1-5, 8'
});
Use preferCSSPageSize: true when the document’s own @page rule should determine paper size rather than the API’s selected format or dimensions.
Include backgrounds and headers or footers
Background graphics are off by default. Set printBackground: true to include them. Header and footer templates are also off by default; set displayHeaderFooter: true to enable them. Templates can use injected classes for the print date, document title, and document URL.
There are two important template limitations: scripts inside header or footer templates are not evaluated, and the page’s styles do not apply inside those templates. Keep template markup self-contained and do not rely on page CSS or template scripts to produce the layout.
await page.pdf({
path: 'with-background.pdf',
printBackground: true,
displayHeaderFooter: true,
headerTemplate: '<div><span class="title"></span></div>',
footerTemplate: '<div><span class="pageNumber"></span> / <span class="totalPages"></span></div>'
});
Check the Page API for the available PDF options and current details on template classes. Playwright Page API
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Know the boundaries of this workflow
PDF export is Chromium-only
The documented Playwright PDF export capability is for Chromium. This is a constraint on the PDF export API described in the documentation, not a general claim that Firefox or WebKit cannot display or print documents in other ways. Playwright PDF Export
Free tools Windows power users keep installed
One-click scans. No signup required.
Printing a page is different from opening an existing PDF
Generating a PDF from rendered webpage content and navigating directly to a URL that is already a PDF are separate tasks. The Page API notes that headless mode does not support navigation to a PDF document. Playwright Page API
Options can vary by installed version
The current API reference marks outline and tagged as options added in v1.42, and both default to false. That annotation is not a full compatibility table for older releases. Check the versioned API docs for your installed package before relying on an option, especially in production.
Or skip the browser setup
If you need a screenshot or PDF from a webpage without setting up a browser, ScreenshotNeo can return a PNG, JPEG, WebP, or PDF from one GET request. Its cleanup accepts cookie and consent banners and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response reports the page verdict and billing status in headers. It also has an MCP server with screenshot and PDF tools for AI agents. Plans include 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000.
See the ScreenshotNeo API documentation for details. For example, this cURL request saves a PDF of a webpage:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -d format=pdf -o page.pdf
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

