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 →Use Playwright Python’s page.pdf() method, then give the PDF a custom paper height large enough for the rendered document. Playwright does not document an automatic “fit every element onto one page” switch. You must choose either a very tall custom sheet or a normal paper size with pagination or scaling, generate the file, and inspect it for clipping and readability.
The examples below use Chromium and show both API-controlled dimensions and CSS @page sizing.
What “single-page PDF” means in Playwright
A conventional Letter or A4 PDF has a fixed sheet height, so content longer than that height naturally flows onto additional pages. A single-page export instead can mean a custom-height sheet whose height is sufficient for the whole document. That is different from shrinking arbitrary content onto one standard page: reducing scale can preserve one page only by making text and controls harder to read.
The reviewed Playwright API documents paper dimensions, print media, scaling, CSS page-size preference, margins, backgrounds and page ranges. It does not describe a dedicated automatic full-document-to-one-page option, nor a universal maximum height that works for every site.
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 glitches#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.
Prerequisites and a minimal export
Install Playwright and a browser
python -m pip install playwright
python -m playwright install chromium
Save this as export_pdf.py and run it with Python. The URL can be a public page or one served by your local application.
from playwright.sync_api import sync_playwright
URL = "https://example.com"
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto(URL, wait_until="networkidle")
page.pdf(
path="page.pdf",
width="8.5in",
height="20in",
print_background=True,
margin={"top": "0", "right": "0", "bottom": "0", "left": "0"},
)
browser.close()
page.pdf() writes the PDF at path. Without path, it returns the PDF bytes, which is useful when you need to upload the result or return it from a web service. The 20-inch height is illustrative, not a guaranteed fit; measure or adjust it for your content.
Choose the sheet size
Custom width and height
Pass units such as px, in, cm or mm. A numeric value without a unit is interpreted as pixels. For a long report, keep a normal width and increase height until the rendered content fits. Generate a file, open it, and check the bottom edge for clipping.
Standard paper formats
The format option selects a standard paper size; its default is Letter. When format is supplied, it takes priority over width and height. Therefore, use either a standard format or explicit dimensions, not both when you need a custom tall sheet.
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 →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.
CSS-controlled sizing
Put the page size in your print stylesheet and ask Playwright to honor it:
<style>
@page {
size: 8.5in 20in;
margin: 0;
}
@media print {
body { margin: 0; }
}
</style>
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto("https://example.com", wait_until="networkidle")
page.pdf(
path="css-sized.pdf",
prefer_css_page_size=True,
print_background=True,
)
browser.close()
prefer_css_page_size=True gives the CSS @page size priority over width, height or format. Its default is False; in that mode, content is scaled to fit the selected paper size.
Control what gets rendered
Print media versus screen media
PDF generation uses print CSS media by default. That means rules inside @media print apply, and a site’s print layout may hide navigation or alter colors. To capture the screen stylesheet instead, switch media before calling pdf():
page.emulate_media(media="screen")
page.pdf(path="screen-style.pdf", print_background=True)
Backgrounds, margins and color
Background graphics are excluded by default. Set print_background=True when cards, gradients or colored sections are part of the intended output. Margins default to none, but specifying them explicitly avoids surprises when your layout depends on a known edge. Browsers may modify colors for printing; the CSS property -webkit-print-color-adjust can be used when exact colors are required.
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 & 11Rank #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.
@media print {
* {
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
}
Scaling and page ranges
scale defaults to 1 and accepts values from 0.1 through 2. A smaller value can help a fixed sheet hold more content, but test the resulting text size before shipping it. page_ranges selects pages from the generated PDF; it does not measure the document or make it fit on one page.
page.pdf(
path="scaled.pdf",
width="8.5in",
height="20in",
scale=0.85,
page_ranges="1",
print_background=True,
)
Make long or dynamic HTML fit reliably
Wait for the page to be ready
Use an appropriate wait_until value in goto(), and add an explicit wait when JavaScript inserts the content that determines document height.
page.goto("https://example.com/report", wait_until="networkidle")
page.wait_for_selector("main.report-ready")
# Or, for a known short animation:
page.wait_for_timeout(500)
Waiting for a selector is preferable to an arbitrary delay when your application can expose a reliable ready state. If images are lazy-loaded only after scrolling, trigger the relevant behavior before exporting and confirm that their final dimensions are present.
Remove layout constraints that create unexpected pages
Inspect print rules for fixed heights, overflow clipping, sticky elements and large margins. A child with overflow: hidden can hide content even when the outer sheet is tall. Conversely, an element with a forced page break can create an additional page. Keep a print-specific stylesheet for export rather than changing your normal screen layout.
Use a height-selection loop
Because Playwright does not provide an automatic “fit all content” mode, a practical workflow is to start with a conservative height, render, inspect the PDF, and increase the height when the bottom is clipped. For predictable reports, calculate the expected content height in your application and add a safety margin; still inspect representative documents because fonts, wrapping and asynchronous content change layout.
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
Complete reusable Python function
from pathlib import Path
from playwright.sync_api import sync_playwright
def html_to_single_sheet(url: str, output: str, height: str = "20in") -> None:
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page(viewport={"width": 1280, "height": 900}, device_scale_factor=1)
page.goto(url, wait_until="networkidle")
page.wait_for_selector("body")
page.pdf(
path=output,
width="8.5in",
height=height,
print_background=True,
margin={"top": "0", "right": "0", "bottom": "0", "left": "0"},
)
browser.close()
html_to_single_sheet("https://example.com", "output/page.pdf", "24in")
Create the output directory first (for example, Path("output").mkdir(exist_ok=True)) if it does not exist. Adjust the width and height to the aspect ratio your reader actually needs; a tall sheet is not equivalent to a paginated document meant for printing.
Common failures and fixes
The PDF is split into several pages
- Cause: the chosen height is shorter than the rendered content, or a print rule inserts page breaks.
- Fix: increase custom
height, remove unintendedbreak-before/break-afterrules, and verify thatformatis not overriding your dimensions.
The bottom of the page is clipped
- Cause: the sheet ends before late-loaded content finishes, or an ancestor has a fixed height and overflow clipping.
- Fix: wait for a ready selector, ensure images and fonts have loaded, inspect overflow rules, then render with additional height.
Colors or backgrounds are missing
- Cause: print backgrounds are off by default, or print color adjustment changes the palette.
- Fix: pass
print_background=Trueand use-webkit-print-color-adjust: exactwhere exact colors matter.
The result looks different from the browser window
- Cause:
page.pdf()uses print media by default. - Fix: call
page.emulate_media(media="screen")before export, or create explicit print CSS.
Text is unreadably small
- Cause: an aggressive
scalevalue or a standard paper size forced the layout to shrink. - Fix: prefer a taller custom sheet, reduce nonessential margins, and keep scale near
1unless testing proves a smaller value remains legible.
The script hangs or times out
- Cause: the page never reaches the chosen load condition because of ongoing requests.
- Fix: use a less restrictive navigation condition, then wait for a specific application-ready selector and set an explicit timeout appropriate to your page.
Performance, reliability and operational notes
Launch Chromium once and reuse the browser for multiple pages when exporting batches; creating a fresh browser process for every URL adds overhead. Use separate pages or browser contexts when cookies and authentication must not leak between jobs. Keep the viewport, device scale factor, fonts and media mode consistent across runs so layout changes are attributable to your HTML rather than the capture environment.
For reproducible exports, pin the Playwright version in your project, wait for a deterministic ready marker, and retain failed HTML or diagnostic screenshots when a PDF is unexpectedly paginated. A custom sheet can be very tall, so check how your PDF viewer, printer and downstream parser handle it before using it as a printable report. If the document is intended for paper, a normal format with deliberate pagination is usually more readable than extreme shrinking.
Or skip the browser setup
ScreenshotNeo provides a website capture API and MCP server for developers. One GET request can return a clean screenshot or PDF, while its capture pipeline accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets before the shot. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and each response identifies the page verdict and billing status.
For an API call, see the ScreenshotNeo documentation:
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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
Its MCP server includes take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. Every plan includes the features; the Free plan provides 1,000 screenshots each month with no card, and paid plans start at $5 for 3,000. Sign up free to try it.
FAQ
Can Playwright automatically calculate the exact one-page height?
Not through a documented page.pdf() option. Select a suitable custom height or CSS @page size, then inspect and adjust the output.
Should I use CSS @page or Python width and height?
Use Python dimensions when the exporter owns sizing. Use @page with prefer_css_page_size=True when the document’s print stylesheet should define the sheet.
Does page_ranges force one page?
No. It chooses which already-generated pages to include; it does not resize or measure the document.
Frequently Asked Questions
Can I use a standard Letter or A4 page and still keep everything on one page?
Only by changing the layout or shrinking it enough to fit. A custom-height sheet is the practical alternative when preserving normal text size matters.
Why does my screen design change in the PDF?
PDF generation uses print CSS by default. Use print-specific rules or call page.emulate_media(media="screen") before page.pdf().
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
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.

