DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

Puppeteer PDF Options: Page Size, Margins, and Backgrounds

A practical guide to Puppeteer PDF sizing, margins, background graphics, color handling, media types, and common output issues.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
  • 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
  • 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
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
  • 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
  • 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot common PDF output problems

  • The page is the wrong size: check whether format is set; it overrides width and height. If CSS @page dimensions should control the sheet, set preferCSSPageSize: true.
  • CSS page dimensions appear scaled: that is the default behavior when preferCSSPageSize is 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: exact in CSS.
  • The PDF is white when transparency was intended: use omitBackground: true to hide the default white background.
  • The PDF layout differs from the browser view: print media is the default. Call page.emulateMediaType('screen') before page.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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 8 Reams (4,000 Sheets), 92 Bright White, Great for Crisp Ink Printing
  • 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

Bestseller No. 1
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
1 ream (500 sheets) of 8.5 x 11 white copier and printer paper for home or office use; Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$6.97
Bestseller No. 2
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
Sheet size – 8.5 x 11; Thickness – 20 pounds; Brightness – 92 bright white
$6.97
Bestseller No. 3
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$21.96
Bestseller No. 4
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$29.14
Bestseller No. 5
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 8 Reams (4,000 Sheets), 92 Bright White, Great for Crisp Ink Printing
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 8 Reams (4,000 Sheets), 92 Bright White, Great for Crisp Ink Printing
Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$53.19

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.