Recommended Free Tools
Set all four page.pdf() margins to zero, then check your print CSS. A reliable baseline is margin: { top: '0', right: '0', bottom: '0', left: '0' }, printBackground: true when colored backgrounds are missing, and an intentional choice between CSS and Puppeteer page sizing. White space can also come from @page rules, print-only styles, a paper-size mismatch, or the PDF viewer/printer rather than from Puppeteer’s margin option.
Use this zero-margin baseline first
The following Node.js example removes PDF margins while keeping an A4 paper size and printing background graphics:
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'networkidle0' });
await page.pdf({
path: 'output.pdf',
format: 'A4',
printBackground: true,
margin: {
top: '0',
right: '0',
bottom: '0',
left: '0'
}
});
await browser.close();
The margin object controls the PDF page margins. In the current Puppeteer PDFOptions reference (version 25.12.0), that option is unset by default; explicitly setting every side to zero makes the intent unambiguous. Use units such as mm, cm, in, or px when a non-zero inset is required.
First identify what the “border” actually is
Do not change several settings at once. Open the PDF at 100% zoom and determine which of these cases matches what you see:
Outdated 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 matchPC 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 & 11#1 Best Overall
- INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
- LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
- COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
- ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
- HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs
| What you see | Likely cause | Relevant fix |
|---|---|---|
| Content is inset evenly on every side | PDF margins or a CSS @page margin |
Set PDF margins to zero and inspect @page |
| A colored or image background stops before the edge, while layout reaches it | Background graphics were not printed | Set printBackground: true |
| Layout changes only in the PDF | Print media rules are active | Inspect @media print; deliberately choose screen emulation if appropriate |
| The whole page is scaled or has unexpected proportions | CSS page size and PDF paper size disagree | Align them or use preferCSSPageSize |
| The file looks edge-to-edge but a physical print has white edges | Printer hardware’s non-printable area | Use a borderless printer mode or accept the printer limitation; PDF settings cannot remove it |
Remove CSS and PDF margins together
A zero PDF margin does not override a margin declared in CSS. Add an explicit print page rule and reset the document’s outer box when your design is intended to touch the page edge:
@page {
size: A4;
margin: 0;
}
html,
body {
margin: 0;
padding: 0;
}
@media print {
/* Keep only print-specific rules that your PDF needs. */
}
Then keep the Puppeteer options consistent:
await page.pdf({
path: 'output.pdf',
format: 'A4',
margin: { top: '0', right: '0', bottom: '0', left: '0' },
printBackground: true
});
If your stylesheet already defines a different @page margin, remove it or change it intentionally. Also check component-level padding: that creates an inset inside the page even when the PDF margin is zero.
Choose who controls the paper size
Puppeteer can select a standard format such as A4, or you can provide explicit width and height. CSS can also declare a size in @page. The preferCSSPageSize option decides which declaration wins.
| Setting | Behavior | Use it when |
|---|---|---|
preferCSSPageSize: false (default) |
Puppeteer’s format, width, or height governs; a CSS page size may be scaled to fit those dimensions. |
Your application owns the paper format in the PDF call. |
preferCSSPageSize: true |
A CSS @page size takes priority over format, width, or height. |
The document stylesheet is the source of truth, especially for custom page dimensions. |
Do not mix an A4 PDF option with a letter-sized CSS page and expect an unchanged scale. Pick one authority, give the other the same dimensions, and verify the resulting PDF’s page box.
CSS-controlled example
@page {
size: 210mm 297mm;
margin: 0;
}
await page.pdf({
path: 'output.pdf',
preferCSSPageSize: true,
printBackground: true,
margin: { top: '0', right: '0', bottom: '0', left: '0' }
});
Puppeteer-controlled example
await page.pdf({
path: 'output.pdf',
format: 'A4',
preferCSSPageSize: false,
printBackground: true,
margin: { top: '0', right: '0', bottom: '0', left: '0' }
});
Remember that PDF generation uses print media
page.pdf() generates the document with the print CSS media type. Rules inside @media print can hide elements, change colors, add spacing, or alter dimensions compared with the screen view.
Inspect the print stylesheet before assuming that Puppeteer added a border. If the screen layout is specifically the one you need, switch media before creating the PDF:
Rank #2
- CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
- INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
- LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
- PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
- ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴
await page.emulateMediaType('screen');
await page.pdf({
path: 'screen-layout.pdf',
format: 'A4',
printBackground: true,
margin: { top: '0', right: '0', bottom: '0', left: '0' }
});
This is a deliberate rendering choice, not a universal fix. Screen media may omit print-only adjustments that were necessary for pagination, visibility, or readable paper output. Compare both modes with the same page-size settings.
Print backgrounds separately from margins
printBackground defaults to false. When it is disabled, a section can appear white even though its CSS background is present in the browser. Turn it on when background colors, gradients, or images are part of the intended PDF:
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →await page.pdf({
path: 'branded.pdf',
format: 'A4',
printBackground: true,
margin: { top: '0', right: '0', bottom: '0', left: '0' }
});
This option does not remove an actual page margin. Conversely, setting margins to zero cannot make an unprinted background appear. For a transparent page background, Puppeteer’s separate omitBackground option is the relevant control; transparency is not a margin solution.
A repeatable diagnostic procedure
- Save the exact PDF options. Record
format,width,height,margin,preferCSSPageSize, andprintBackground. Check that no wrapper merges another options object afterward. - Inspect
@page. Search all loaded stylesheets for@page, especially declarations inside imported print CSS. Note bothmarginandsize. - Inspect print rules. Search
@media printfor padding, width changes, hidden backgrounds, and alternate layout containers. Generate a second file afteremulateMediaType('screen')only if screen rendering is the requirement. - Align dimensions. Use matching CSS and Puppeteer dimensions, or set
preferCSSPageSize: truewhen CSS should win. - Separate layout from paint. Temporarily apply a visible outline to the page wrapper. If the outline reaches the page edge but the fill does not, the issue is background printing rather than a margin.
- Check the viewer and printer. Disable viewer options such as “fit” or “shrink” while diagnosing. A physical printer can add unavoidable white edges even when the PDF page itself is edge-to-edge.
Common failures and fixes
Zero margins still leave a white strip
Look for @page { margin: ... }, a body or wrapper margin, or padding on the first full-page container. CSS declarations can create visible insets independently of PDFOptions.
The page is the wrong size after adding preferCSSPageSize
That option intentionally gives CSS @page dimensions priority. Remove it when format, width, or height should control, or correct the CSS size.
Background is white but content reaches the edge
Enable printBackground: true. Confirm that the background is applied to an element that exists in print media and is not replaced by an @media print rule.
Rank #3
- SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
- INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
- KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
- PREMIUM SUPPORT - Strong technical expertise to solve issues faster
- THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.
The PDF differs from the browser screenshot
That is expected when print CSS is different. Compare a print-media capture with a screen-media capture and decide which stylesheet the PDF is supposed to represent.
Changing omitBackground did not remove the border
omitBackground concerns transparency. It does not change page margins, CSS spacing, or paper dimensions.
Only printed paper has the border
Open the PDF itself at 100%. If the file reaches the edge but the paper does not, the printer’s printable area is the limiting factor. Use a printer’s borderless mode if available; do not keep changing Puppeteer margins for a hardware constraint.
Production checklist
- Set all four PDF margins explicitly, even when they are zero.
- Declare one authoritative page size and keep CSS and PDF options consistent.
- Decide intentionally between print and screen media.
- Enable
printBackgroundwhen the design depends on backgrounds. - Test a page with long content, a short page, images, and every supported paper size.
- Inspect the PDF page itself before troubleshooting a physical print.
- Keep a known-good options object in source control so later changes can be compared.
Or skip the browser setup
If your actual requirement is a clean website capture rather than a Puppeteer PDF produced inside your application, ScreenshotNeo provides a one-request screenshot API and an MCP server for AI agents. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and each response identifies the page verdict and billing status.
Use the documented call (the API can return PNG, JPEG, WebP, or PDF according to the request):
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 the available capture parameters. Its MCP tools include take_screenshot, get_page_info, and capture_pdf, so Claude, Cursor, or another MCP client can request captures without you maintaining a browser setup. Every plan includes all features; 1,000 screenshots per month are free with no card, and paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
Frequently asked questions
Can Puppeteer remove the unprintable edge of my office printer?
No. Puppeteer controls the PDF page and its content; a printer may still reserve a physical non-printable area. Use the printer’s borderless mode when supported.
Rank #4
- Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
- No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
- Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
- Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
- The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art
Should I always set preferCSSPageSize to true?
No. Set it to true when CSS @page dimensions should control. Leave the default false when the PDF call’s format or explicit dimensions are authoritative.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Does printBackground: true make a PDF margin disappear?
No. It prints background graphics. Margin removal requires the PDF margin settings and, when applicable, CSS @page and element spacing changes.
Why does changing to screen media affect pagination?
Screen and print styles can define different visibility, sizes, and spacing. Emulating screen media changes which rules apply, so pagination must be checked again.
Frequently Asked Questions
Can Puppeteer remove the unprintable edge of my office printer?
No. Puppeteer controls the PDF page and its content; a printer may still reserve a physical non-printable area. Use the printer’s borderless mode when supported.
Should I always set preferCSSPageSize to true?
No. Set it to true when CSS @page dimensions should control. Leave the default false when the PDF call’s format or explicit dimensions are authoritative.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsDoes printBackground: true make a PDF margin disappear?
No. It prints background graphics. Margin removal requires the PDF margin settings and, when applicable, CSS @page and element spacing changes.
Why does changing to screen media affect pagination?
Screen and print styles can define different visibility, sizes, and spacing. Emulating screen media changes which rules apply, so pagination must be checked again.
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.

