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 & 11Control Playwright PDF margins with the four-sided margin option on page.pdf(), or define them in CSS with an @page rule. Use explicit units such as mm, decide which layer owns page size, and avoid conflicting settings. Playwright uses print CSS by default, so your print stylesheet and API options both affect the final whitespace.
Set margins with page.pdf()
The API margin object is the most direct choice when export code should control each PDF. Each side accepts a value with units: px, in, cm, or mm. Unlabeled numbers are interpreted as pixels. Paper margins default to none, and each side defaults to 0.
JavaScript or TypeScript
import { chromium } from 'playwright';
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.pdf({
path: 'output.pdf',
format: 'A4',
margin: {
top: '20mm',
right: '15mm',
bottom: '20mm',
left: '15mm'
},
printBackground: true
});
await browser.close();
Python (async API)
from playwright.async_api import async_playwright
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch()
page = await browser.new_page()
await page.goto("https://example.com", wait_until="networkidle")
await page.pdf(
path="output.pdf",
format="A4",
margin={
"top": "20mm",
"right": "15mm",
"bottom": "20mm",
"left": "15mm",
},
print_background=True,
)
await browser.close()
import asyncio
asyncio.run(main())
Use format for a named paper size such as A4 or Letter. If format is supplied, it takes priority over width and height; Letter is the default format. For custom paper, omit format and provide dimensions with units.
Set margins with CSS @page
CSS is preferable when print layout belongs to the document itself and should also work through browser print styles.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
@page {
size: A4;
margin: 20mm 15mm 20mm 15mm;
}
@media print {
body {
margin: 0;
}
}
The four-value order is top, right, bottom, left. A single value applies to all sides; two values apply to top/bottom and right/left. CSS2 defines page-level margins, including @page { margin: 2cm } (W3C CSS2, page layout specification).
Choose one authoritative layer
Use the API margin object when
- Different exports need different margins.
- A job or service should enforce margins independently of page markup.
- You want the export function’s settings visible beside the PDF call.
Use @page when
- Designers own print CSS.
- The same rules must apply to browser printing and Playwright.
- Page size and margins are part of a reusable stylesheet.
Both mechanisms can exist, but mixing competing values makes debugging difficult. Keep one source authoritative and verify the produced PDF at the intended paper size.
Make CSS page size win with preferCSSPageSize
If CSS declares the page size and it must outrank API format, width, or height, set preferCSSPageSize: true (Python: prefer_css_page_size=True). The documented default is false; with that default, content is scaled to fit the requested paper size.
await page.pdf({
path: 'invoice.pdf',
format: 'A4',
preferCSSPageSize: true
});
await page.pdf(
path="invoice.pdf",
format="A4",
prefer_css_page_size=True,
)
Set this only when CSS is the intended owner. Otherwise, omit it and let the API paper setting control the sheet.
Print media, screen media, and backgrounds
page.pdf() generates a PDF using print CSS media by default, as documented by Playwright. Rules inside @media print therefore apply automatically. To render screen styles instead, switch media before exporting:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
await page.emulateMedia({ media: 'screen' });
await page.pdf({ path: 'screen-styled.pdf', format: 'A4' });
await page.emulate_media(media="screen")
await page.pdf(path="screen-styled.pdf", format="A4")
Backgrounds are not printed unless requested. Set printBackground: true (Python: print_background=True) when colored panels, images, or background fills are part of the design. The API default is false. The scale option defaults to 1 and accepts values from 0.1 to 2; changing it alters apparent whitespace and available content area, so do not use scale to compensate for an incorrect margin.
Remove unwanted default whitespace
- Set all four API margins explicitly to
0if the export should be edge-to-edge. - Reset document margins in print CSS:
@media print { body { margin: 0; } }. - Check component styles for padding on wrappers, headers, and footers.
- Confirm the selected paper size and whether CSS page size is preferred.
- Export again and inspect the PDF’s actual page boundary, not just the browser preview.
await page.pdf({
path: 'no-margins.pdf',
format: 'A4',
margin: { top: '0', right: '0', bottom: '0', left: '0' }
});
Zero paper margins do not remove padding inside your HTML. They only remove the PDF paper margin supplied by the API.
Why Playwright adds unexpected whitespace
Two page-size systems are interacting
A CSS @page size combined with preferCSSPageSize: false can produce surprising scaling or whitespace. Playwright issue #34423, opened January 15, 2025 against version 1.49.1, reports extra margins with an @page rule even when zero margins were tried in CSS and in page.pdf(). If CSS sizing is intended, reproduce with preferCSSPageSize: true, then inspect the effective print styles and the selected API size.
Free tools Windows power users keep installed
One-click scans. No signup required.
The body has its own margin
Browsers commonly apply a user-agent body margin. Override it in the print stylesheet rather than assuming an API margin of zero will remove it.
Scaling changes the apparent edge
An API format can cause content designed for a different CSS page size to be scaled. Check format, width, height, scale, and preferCSSPageSize together.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Headers, footers, and positioned elements
Fixed or absolutely positioned elements can look like margins when they reserve space or overlap content. Test with those elements hidden, then restore them with deliberate print-only dimensions.
Units and page-size examples
| Goal | JavaScript setting | Python setting |
|---|---|---|
| A4 with 20 mm top/bottom and 15 mm sides | format: 'A4', margin: {top:'20mm', right:'15mm', bottom:'20mm', left:'15mm'} |
format='A4', margin={'top':'20mm','right':'15mm','bottom':'20mm','left':'15mm'} |
| No API paper margin | margin: {top:'0', right:'0', bottom:'0', left:'0'} |
Same keys and values in the Python dictionary |
| Custom physical size | width: '210mm', height: '297mm' |
width='210mm', height='297mm' |
| CSS controls paper size | preferCSSPageSize: true |
prefer_css_page_size=True |
Prefer physical units for documents that must print consistently. Pixels are valid, but their relationship to physical paper depends on the rendering and conversion context.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Reliability checklist for production PDFs
- Wait for the page’s required data and fonts before export; otherwise late layout shifts can change page breaks.
- Use
waitUntil: 'networkidle'only when it matches your application; pages with persistent analytics connections may never become idle. - Specify paper size and all four margins rather than relying on defaults.
- Keep print CSS free of accidental body or wrapper padding.
- Choose print or screen media intentionally.
- Enable backgrounds explicitly when visual fidelity requires them.
- Validate representative pages: first page, a dense middle page, and the final page.
Common errors and fixes
“The margin option has no effect”
Check that you are calling page.pdf() after navigation and that the values include valid units. Then look for internal CSS padding or a wrapper width that creates the apparent margin.
“My CSS margin is ignored”
Confirm the stylesheet is loaded, the rule is @page rather than a normal selector, and that print media is active. If CSS also sets page size, use preferCSSPageSize: true.
“The PDF is the wrong paper size”
When format is present, it outranks width and height. Remove it for custom dimensions, or enable CSS page-size preference when CSS owns sizing.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
“Content is clipped after reducing margins”
Inspect fixed-width elements, tables, and print-only positioning. Reducing paper margins does not make an oversized child fit; adjust the child or use a deliberate scale.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
“Colors or backgrounds disappeared”
Set printBackground: true and check for print CSS that removes backgrounds.
Or skip the browser setup
ScreenshotNeo provides a website screenshot API and MCP server; it is not a replacement when you need Playwright’s local DOM control, but it can produce a PDF from a URL with one request and exposes paper size, margins, landscape mode, and page ranges as options. Cookie and consent banners, newsletter popups, and chat widgets can be removed before capture. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP tools let Claude, Cursor, or another MCP client call take_screenshot, get_page_info, and capture_pdf.
See the ScreenshotNeo documentation for request parameters. A one-call image example is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
For PDF output, add the documented PDF and margin parameters to the same request. ScreenshotNeo includes 1,000 shots per month free with no card; paid plans start at $5 for 3,000 shots, and every feature is on every plan. Create a free ScreenshotNeo account.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesFrequently Asked Questions
Can I use both CSS and API margins?
Yes, but choose one as authoritative and make page-size precedence explicit; otherwise scaling and whitespace are difficult to diagnose.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
What is the default Playwright PDF margin?
The documented paper-margin default is none, with each margin side defaulting to 0. HTML body and wrapper styles can still create visible whitespace.
How do I make CSS page size override format?
Define size in @page and set preferCSSPageSize: true in JavaScript or prefer_css_page_size=True in Python.
Does page.pdf() use print styles?
Yes. It uses print CSS media by default; call emulateMedia or emulate_media with screen when screen styles are required.
Recommended Free Tools
The Bottom Line
Use explicit four-sided API margins for export-specific control, or keep margins and page size in @page with preferCSSPageSize when CSS owns print layout. Reset body margins, select media deliberately, and verify paper-size precedence before chasing whitespace.
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.

