Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsIf Puppeteer produces a PDF with the wrong page dimensions, start by choosing one place to control the paper size: the page.pdf() options or CSS @page. Puppeteer gives format priority over width and height; with preferCSSPageSize: true, a CSS page size takes priority over those API settings. The method also prints using print CSS by default, so the screen layout is not a reliable guide to the PDF.
How Puppeteer decides the PDF page size
A Puppeteer PDF is a paged print document, not a screenshot of the browser viewport. Chromium lays out content for physical page boxes, applies margins, then fragments content across pages. Set the paper dimensions through either Puppeteer’s PDF options or a CSS @page rule, and make the other layer non-conflicting.
The current Puppeteer PDF options reference documents these controls and their precedence: PDFOptions. In particular, format overrides width and height. The default for preferCSSPageSize is false; set it to true to give CSS @page dimensions priority over the API’s paper dimensions. Without that preference, content is scaled to fit the paper size.
Chrome’s print model uses CSS @page to define page size and margins; see Chrome for Developers’ print CSS guide.
#1 Best Overall
- BEST FOR SMALL BUSINESSES – Engineered for extraordinary productivity, the Brother DCP-L2640DW Monochrome (Black & White) 3-in-1 combines laser printer, scanner, copier in one compact footprint and delivers high-quality black & white prints
- FAST PRINTER WITH EFFICIENT SCANNING – Produces documents quickly with print speeds up to 36 ppm(2) and scan speeds up to 23.6/7.9 ipm(3) (black/color). A 50-page auto document feeder(4) allows for convenient, time saving multi-page scanning and copying
- FLEXIBLE CONNECTION OPTIONS – Easily navigate the changing demands of your business with secure multi-device connectivity via built-in dual-band wireless (2.4GHz / 5GHz) and Ethernet. Or connect locally to a single computer via USB interface
- BROTHER MOBILE CONNECT APP – Print, scan, and manage your wireless printer anytime, from almost anywhere from your mobile device. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(5)
- CHOOSE BROTHER GENUINE TONER – When it’s time to replace your toner, be sure to choose Brother Genuine TN830 or TN830XL replacement toner. And with Refresh EZ Print Subscription Service, you’ll never worry about running out of toner again and you’ll enjoy savings of up to 50%(6) on Brother Genuine Toner. Get started with Refresh today with a Free Trial(1)
Choose one owner for page size
Let Puppeteer set the paper size
Use this approach when the output must use a named format or dimensions chosen by application code. Remove or neutralize conflicting @page { size: ... } rules, and leave preferCSSPageSize false.
await page.pdf({
path: 'out.pdf',
format: 'A4',
landscape: false,
margin: { top: '0mm', right: '0mm', bottom: '0mm', left: '0mm' },
preferCSSPageSize: false,
printBackground: true
});
Here, A4 is the API-owned paper size, and the margin is explicitly set to zero. If a nonzero border is intended, set each margin to the required physical value instead. Do not also pass custom width and height expecting them to supersede format.
Let CSS set the paper size
Use this approach when the page’s print stylesheet owns the document’s physical dimensions. Define one @page size, enable preferCSSPageSize, and avoid contradictory API dimensions.
/* Print stylesheet */
@page {
size: 210mm 297mm;
margin: 0;
}
@media print {
html, body { margin: 0; }
}
await page.pdf({
path: 'out.pdf',
preferCSSPageSize: true,
printBackground: true
});
The dimensions above specify a portrait sheet using millimeters. CSS page margins and HTML body margins are separate layers; set both deliberately if edge spacing matters.
Rank #2
- BEST FOR HOMES & HOME OFFICES – Engineered for consistent, premium print quality, the Brother HL-L2405W Monochrome (Black & White) Laser Printer delivers sharp, crisp prints at an affordable price. Prints one-sided documents at speeds up to 30ppm(2)
- COMPACT, CONNECTED PRINTER – Flexible connection options make this an ideal printer for home use and at-home offices. Securely connect to multiple devices with built-in dual-band wireless (2.4GHz/5GHz) or locally to a single computer via USB interface
- BROTHER MOBILE CONNECT APP – Manage your printer remotely and print from your mobile device anytime, from almost anywhere. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(3)
- VERSATILE PAPER HANDLING – Enjoy seamless, reliable everyday printing with the 250-sheet paper tray(4) and a manual feed slot that enables printing on envelopes and specialty pape
- BROTHER IS AT YOUR SIDE – Backed by Brother with a 1-year limited warranty and free online, call, or live chat support for the life of your printer
When to use width and height
For a custom physical page, use strings with units such as mm, cm, or in, and omit format. Puppeteer accepts numeric dimensions too, while the underlying Chrome DevTools Protocol expresses paper width and height in inches. The protocol lists default paper dimensions of 8.5 × 11 inches (Letter) and default margins of about 1 cm per side; explicit settings avoid relying on those defaults. See the Chrome DevTools Protocol printToPDF reference.
Do not combine a named format with custom dimensions unless you intentionally want the named format to win. If the intended dimensions are custom, remove format and make the API the sole size owner, or define the dimensions in CSS and enable preferCSSPageSize.
Why a correctly sized PDF can still look wrong
Margins appear as white borders
Visible whitespace may come from Puppeteer’s PDF margin, CSS @page margins, or margins on html and body. These are distinct controls. Set one page-margin layer intentionally and inspect the print styles for body margins, padding, borders, and reserved space. A zero PDF margin does not remove a CSS body margin.
Print styles change the layout
page.pdf() uses the print media type by default: Puppeteer’s documentation says it “Generates a PDF of the page with the print CSS media type.” See the page.pdf API reference. Rules under @media print may change width, visibility, display, overflow, or other layout properties. Inspect what the page looks like under print media rather than reasoning only from its screen appearance.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
- FAST PRINT SPEEDS: Print up to 19 pages per minute.
- COMPACT DESIGN: Space-saving, compact design fits anywhere in your home, school or small office.
- WIRELESS CONNECTIVITY: Print from almost anywhere in your workspace using your compatible mobile device.
- PAPER CAPACITY: Up to 150 sheets.
- SUSTAINABILITY: Uses less than 2 watts in Energy Saver mode.
To explicitly inspect the print layout before generating the PDF, call await page.emulateMediaType('print'). To use screen rules instead, call await page.emulateMediaType('screen') before page.pdf(). This changes the media rules used for rendering; it does not make the viewport the paper size.
Viewport size is mistaken for paper size
page.setViewport() controls browser layout conditions, such as the viewport width used by responsive CSS. It does not, by itself, define the PDF’s physical sheet. Set the PDF options or CSS @page explicitly. The distinction is why a page that looks correctly proportioned in the browser can paginate differently in the generated file.
Print output changes colors or omits backgrounds
Print rendering may alter colors. If exact color reproduction is required, use -webkit-print-color-adjust in the applicable CSS. Set printBackground: true when the PDF should include page backgrounds. For example:
@media print {
html {
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
}
These settings address print appearance; they do not change paper dimensions or fix conflicting size declarations.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchRank #4
- BEST FOR HOME OFFICES & SMALL TEAMS – Engineered for consistent, premium print quality, the Brother HL-L2460DW Monochrome (Black & White) Laser Printer produces documents that are clear, crisp, and easy to review and share, all at an affordable price
- COMPACT, CONNECTED, EXCEPTIONALLY EFFICIENT– Connect with built-in dual-band wireless (2.4GHz/5GHz), Ethernet, or to a single computer via USB interface. Prints at speeds up to 36ppm(2), plus automatic duplex printing saves time and reduces paper waste
- BROTHER MOBILE CONNECT APP – Manage your wireless printer remotely and print from your mobile device anytime, from almost anywhere. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(3)
- VERSATILE PAPER HANDLING – Tackle high-volume black & white printing with the 250-sheet capacity paper tray.(4) The manual feed slot enables printing on envelopes and specialty paper
- BROTHER IS AT YOUR SIDE – Backed by Brother with a 1-year limited warranty and free online, call, or live chat support for the life of your printer
Fonts, images, or other content arrive late
A PDF captured before layout-critical assets are ready may have different wrapping or pagination than expected. Puppeteer’s waitForFonts option is documented with a default of true, but application code still needs to wait for navigation, asynchronously inserted content, and images that matter to layout. Where appropriate, wait for your application’s own ready state before printing; a generic network-idle condition may not mean client-side rendering is complete.
Custom dimensions cause rounding or fragmentation symptoms
Historical reports describe small dimension discrepancies and repeated edge artifacts with some custom-size configurations. Such reports are version- and scenario-sensitive, not proof of a universal current Chromium defect. First reproduce the issue with a standard named size such as A4 or Letter. If the standard size works but a custom size does not, reduce the page to a minimal example and compare against the exact Puppeteer and Chromium versions used in deployment. The historical issue discussing these interactions is Puppeteer issue 2278.
An unexpected extra or blank page appears
There is no single universal cause. Fractional dimensions, overflow, transforms, borders, fixed heights, or content that slightly exceeds the printable area can produce another page fragment. Start with a minimal document: remove body margins, borders, transforms, and overflow constraints, then add them back one at a time. Check whether the content box fits inside the paper after margins are applied.
A practical debugging sequence
- Log the exact PDF options. Record the object passed to
page.pdf()so you can spot unexpectedformat, dimensions, margins, orpreferCSSPageSizevalues. - Find every print-size declaration. Search loaded stylesheets for
@page,@media print,size,margin,transform, fixedheight, and overflow rules. - Choose API-owned or CSS-owned size. Configure just one source of truth. Remember that
formatwins overwidthandheight, whilepreferCSSPageSize: truegives CSS@pagepriority. - Establish a named-size baseline. Try
format: 'A4'orformat: 'Letter'before debugging custom dimensions. This helps distinguish a general print-layout problem from a custom-size-specific symptom. - Set margins explicitly. Specify Puppeteer margins and CSS page/body margins intentionally; do not infer that one zero-margin setting clears the others.
- Wait for the page to be ready. Ensure navigation, application rendering, fonts, and layout-critical images have completed before calling
page.pdf(). - Inspect print rendering and the resulting file. Use print media emulation to inspect styles, then verify the generated PDF’s physical page dimensions with a PDF inspector.
- Compare deployment versions. Record the Puppeteer and Chromium versions and reproduce with those exact versions; printing behavior may change as the browser updates.
Options that affect the result
| Option or setting | What it controls | Diagnostic significance |
|---|---|---|
format |
Named paper size, such as A4 or Letter. | Takes priority over width and height. |
width and height |
Explicit PDF paper dimensions. | Use physical-unit strings for clarity; omit format when custom dimensions are intended. |
preferCSSPageSize |
Whether a CSS @page size takes priority over API dimensions. |
False by default; set true when CSS owns the paper size. |
margin |
PDF page margins. | Set explicitly to avoid protocol defaults; also inspect CSS page and body margins. |
landscape |
Landscape orientation for the API-selected paper. | Check that orientation agrees with CSS @page when both layers are present. |
printBackground |
Whether backgrounds are printed. | Affects appearance, not paper dimensions. |
waitForFonts |
Whether Puppeteer waits for fonts before printing. | Documented default is true; still wait for app content and images where needed. |
For the complete option set and current details, consult Puppeteer’s PDFOptions reference.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
- FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for small teams printing professional-quality black & white documents and reports. Perfect for 1-3 people
- WORLD'S SMALLEST LASER IN ITS CLASS – Precision laser printing that fits anywhere
- FAST PRINT SPEEDS – Up to 21 black-and-white pages per minute single-sided
- WIRELESS WITH SELF-RESET – Helps you stay connected
- PRINT FROM ANY DEVICE – Wireless printing from any mobile device, PC or tablet. Works with Microsoft, Mac, AirPrint, Android, Chromebook and more
Or skip the browser setup
If the actual requirement is a screenshot image or a PDF capture of a page—not custom Puppeteer print-layout debugging—ScreenshotNeo offers a one-request capture endpoint. It does not replace Puppeteer when you need application-controlled print CSS, but it can avoid maintaining a browser capture flow for straightforward page captures. See the ScreenshotNeo API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie or consent banners as a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots. Every feature is on every plan.
Sign up free for 1,000 screenshots a month with no card.
FAQ
Should I use emulateMediaType('screen') before generating a PDF?
Only if you intend to render screen CSS. Puppeteer uses print media by default; switching to screen changes which media rules apply, but does not define the paper dimensions.
Does landscape: true override a portrait @page rule?
Do not rely on contradictory orientation declarations. Make the API or CSS the explicit owner of the page setup, then verify the generated PDF’s physical dimensions.
Why does A4 work when my custom width and height do not?
Named-format output is a useful control case. If the issue appears only with custom dimensions, isolate a minimal page and check the units, margins, Chromium version, and whether CSS is also declaring a page size.
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.




