What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Set PDF dimensions, margins, and background rendering in the options passed to page.pdf(). Puppeteer defaults to Letter paper, print CSS, and no printed background graphics. For predictable output, decide whether the page’s CSS @page rule or Puppeteer’s paper settings should control the sheet, then set the margins and background options explicitly.
Set paper size and choose which setting controls it
In Puppeteer’s PDFOptions, use format for a standard paper size or width and height for custom dimensions. The documented default format is letter. When format is set, it takes precedence over width and height. Use explicit units for custom dimensions so the intended measurement is clear.
As an Amazon Associate I earn from qualifying purchases.
CSS can also set sheet dimensions with @page. By default, preferCSSPageSize is false: Puppeteer scales the CSS-defined page to fit the paper size selected through the API. Set it to true when the CSS page size should take priority.
const pdf = await page.pdf({
format: 'A4',
printBackground: true,
margin: {
top: '12mm',
right: '12mm',
bottom: '12mm',
left: '12mm'
}
});
Choose one sizing approach deliberately. If using format, do not expect conflicting width or height values to override it. If the document’s CSS defines its own paper size, enable preferCSSPageSize to avoid scaling that CSS size to the API-selected paper.
#1 Best Overall
- 1 ream (500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
- Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
- Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
- Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
- Virgin copy paper providing professional quality results; acid-free to prevent yellowing
Common documented paper formats
| Format | Dimensions |
|---|---|
| Letter | 8.5 × 11 in (21.59 × 27.94 cm) |
| Legal | 8.5 × 14 in (21.59 × 35.56 cm) |
| Tabloid | 11 × 17 in (27.94 × 43.18 cm) |
| Ledger | 17 × 11 in (43.18 × 27.94 cm) |
| A4 | 8.2677 × 11.6929 in (21 × 29.7 cm) |
| A3 | 11.6929 × 16.5354 in (29.7 × 42 cm) |
| A5 | 5.8268 × 8.2677 in (14.8 × 21 cm) |
These are dimensions listed in Puppeteer’s format documentation; they are not independent measurements of generated PDF output. See the PaperFormat reference and PDFOptions reference.
Set each margin independently
The optional margin object accepts top, right, bottom, and left values. Each can be a string or number. If you omit the margin object, Puppeteer sets no margins through this option.
const pdf = await page.pdf({
format: 'Letter',
margin: {
top: '0.5in',
right: '0.4in',
bottom: '0.5in',
left: '0.4in'
}
});
Use explicit units in string values—such as mm or in—to make the intended page geometry easy to review. The PDFMargin reference documents the four sides.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
- HP Papers is sourced from renewable forest resources and has achieved production with 0% deforestation in North America. Each ream is wrapped in a polyurethane coated paper wrapper to protect the cut sheets from moisture damage
- Sheet size – 8.5 x 11; Thickness – 20 pounds; Brightness – 92 bright white
- HP Copy&Print20 20 pounds printer paper is Forest Stewardship Council (FSC) certified and contributes toward satisfying credit MR1 under LEED (Leadership in Energy and Environmental Design)
- All HP Papers provide premium performance on HP equipment, as well as on all other printer and copier equipment; 100% satisfaction guaranteed; ColorLok technology provides more vivid colors, bolder blacks and faster drying
- Superior quality, reliability, and dependability for high-volume printing at home, at school and in the office; HP Copy&Print20 print and copy paper prevents yellowing over time to ensure a long-lasting appearance for added archival quality
Print backgrounds and control color output
printBackground defaults to false, so background graphics are omitted unless you set it to true. Separately, omitBackground hides the default white background and permits PDF transparency. These settings address different concerns: use printBackground to include page background graphics, and omitBackground when a white page background should not be added.
const pdf = await page.pdf({
format: 'A4',
printBackground: true
});
Print rendering modifies colors by default. Puppeteer’s Page.pdf() documentation identifies the CSS property -webkit-print-color-adjust for forcing exact colors. Apply it in the page’s stylesheet when color fidelity matters:
*, *::before, *::after {
-webkit-print-color-adjust: exact;
}
Including backgrounds and requesting exact print colors are separate controls: enable printBackground for background graphics, and use the CSS color-adjust property when print color adjustment is undesirable. See Page.pdf() and PDFOptions.
Rank #3
- 3 ream case (1,500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
- Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
- Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
- Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
- Virgin copy paper providing professional quality results; acid-free to prevent yellowing
Use print CSS or screen CSS
page.pdf() renders with the print CSS media type. The official reference describes it as generating a PDF of the page with the “print” CSS media type. If the PDF should reflect screen styles instead, call page.emulateMediaType('screen') before generating it.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →await page.emulateMediaType('screen');
const pdf = await page.pdf({
format: 'A4',
printBackground: true
});
Pick the media type based on the intended document: print styles may hide navigation or reflow content, while screen styles may preserve the layout used in a browser window. The PDF API uses print media unless you change it explicitly.
Combine options in a runnable Node.js example
This example navigates to a page, creates an A4 PDF with explicit margins and backgrounds, and writes the result to disk. Replace the URL with the page you need to capture.
Rank #4
- 5 ream case (2,500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
- Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
- Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
- Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
- Virgin copy paper providing professional quality results; acid-free to prevent yellowing
const puppeteer = require('puppeteer');
const fs = require('node:fs/promises');
(async () => {
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'networkidle0' });
const pdf = await page.pdf({
format: 'A4',
printBackground: true,
margin: {
top: '12mm',
right: '12mm',
bottom: '12mm',
left: '12mm'
}
});
await fs.writeFile('page.pdf', pdf);
} finally {
await browser.close();
}
})();
To let the document’s CSS determine its paper size, add preferCSSPageSize: true and define an @page size in the page stylesheet. To use landscape orientation, add landscape: true. For custom paper dimensions instead of a named format, use width and height with explicit units.
Check WebDriver BiDi compatibility
Puppeteer’s WebDriver BiDi support page lists these Page.pdf() options for that mode: format, height, landscape, margin, pageRanges, printBackground, scale, and width. It does not list every option in the general PDFOptions reference. If your runtime uses WebDriver BiDi, check the WebDriver BiDi support documentation before relying on options such as preferCSSPageSize or omitBackground.
Recommended Free Tools
Troubleshoot common PDF output problems
- The page is the wrong size: check whether
formatis set; it overrideswidthandheight. If CSS@pagedimensions should control the sheet, setpreferCSSPageSize: true. - CSS page dimensions appear scaled: that is the default behavior when
preferCSSPageSizeis false. Enable it to prioritize CSS page size. - Background images or colors are missing: set
printBackground: true. For exact print colors, also apply-webkit-print-color-adjust: exactin CSS. - The PDF is white when transparency was intended: use
omitBackground: trueto hide the default white background. - The PDF layout differs from the browser view: print media is the default. Call
page.emulateMediaType('screen')beforepage.pdf()if screen styles are required. - An option does not work in a BiDi runtime: compare it with the options listed for WebDriver BiDi; that support list is narrower than the general reference.
Or skip the browser setup
If you need a screenshot or PDF from a URL without managing a Puppeteer browser, ScreenshotNeo returns an image or PDF from one GET request. Its capture flow accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses identify the page verdict and billing status in headers. ScreenshotNeo also provides an MCP server for AI agents, with tools including take_screenshot, get_page_info, and capture_pdf.
For a WebP screenshot, the request is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free and try ScreenshotNeo.
Best Value
- 8 ream case (4,000 sheets) of 8.5 x 11 white copier and printer paper for home or office use
- Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
- Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
- Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
- Virgin copy paper providing professional quality results; acid-free to prevent yellowing
Frequently Asked Questions
Can I use Puppeteer to set a custom PDF page size?
Yes. Set width and height with explicit units, and leave format unset because a specified format takes precedence over those dimensions.
Does printBackground make a PDF transparent?
No. It enables printing background graphics. omitBackground is the option that hides the default white background and permits transparency.
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.




