What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use a headless browser to print the HTML. Puppeteer or Playwright renders the same DOM and CSS engine used by a browser, waits for the page’s assets, and writes a PDF with page.pdf(). For a local file, navigate to an absolute file:// URL; for a web page, use its HTTPS URL. Set print media, paper geometry, backgrounds and page-break rules explicitly so the result is repeatable.
Choose a browser-based converter
Browser rendering is usually more faithful than drawing text and shapes directly into a PDF library: CSS layout, web fonts, SVG, responsive components and JavaScript-generated data are evaluated before printing.
| Library | Best fit | PDF considerations |
|---|---|---|
| Puppeteer | Chromium-focused Node.js services and scripts | page.pdf() prints with the print CSS media type by default, supports standard formats such as A4, and waits for fonts by default. |
| Playwright | Projects that may also automate multiple browser engines | page.pdf() supports standard formats, explicit width and height, CSS units, margins and background printing; it also defaults to print media. |
Install one library in your project, and install its managed browser binaries according to that library’s setup instructions. The examples below use ECMAScript modules, so use a recent Node.js release and set "type": "module" in package.json (or convert the imports to require() for CommonJS).
Convert a local HTML file with Puppeteer
Save this as html-to-pdf.js. Replace the example path with an absolute path. An absolute URL avoids ambiguity about the process working directory.
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
- 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.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.goto('file:///absolute/path/report.html', {
waitUntil: 'networkidle2'
});
await page.pdf({
path: 'report.pdf',
format: 'A4',
printBackground: true,
margin: { top: '16mm', right: '14mm', bottom: '16mm', left: '14mm' }
});
} finally {
await browser.close();
}
networkidle2 is a useful baseline for pages whose images, stylesheets and scripts load during navigation. It is not a guarantee that an application’s data is ready: long-polling, delayed charts and timers can keep changing the DOM after network activity becomes quiet.
Return PDF bytes instead of writing a file
Omit path and keep the returned value for an HTTP response, object-storage upload or database record:
const pdfBytes = await page.pdf({
format: 'A4',
printBackground: true,
margin: { top: '16mm', right: '14mm', bottom: '16mm', left: '14mm' }
});
// Example for an HTTP response: res.type('application/pdf').send(pdfBytes);
Convert a URL
Use the same call, changing only the navigation target:
await page.goto('https://example.com/invoice/123', { waitUntil: 'networkidle2' });
await page.pdf({ path: 'invoice.pdf', format: 'Letter', printBackground: true });
For authenticated pages, establish the session before printing (for example, navigate through a login flow or load the required cookies). Never put credentials in a public URL.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minutePlaywright implementation
import { chromium } from 'playwright';
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.goto('file:///absolute/path/report.html', { waitUntil: 'networkidle' });
await page.pdf({
path: 'report.pdf',
format: 'A4',
printBackground: true,
margin: { top: '16mm', right: '14mm', bottom: '16mm', left: '14mm' }
});
} finally {
await browser.close();
}
Playwright’s PDF options also accept CSS lengths and explicit width/height. Use a standard format when possible because it communicates intent to printers and downstream tools.
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.
Use the screen stylesheet deliberately
Both documented APIs print with the print media type by default. If your screen stylesheet is intentionally the source of truth, switch media before creating the PDF:
// Puppeteer
await page.emulateMediaType('screen');
await page.pdf({ path: 'screen-layout.pdf' });
// Playwright
await page.emulateMedia({ media: 'screen' });
await page.pdf({ path: 'screen-layout.pdf' });
Do this only when you have checked that screen spacing, navigation and interactive controls make sense on paper.
Make print CSS predictable
@media print {
.no-print { display: none !important; }
h1, h2, h3 { break-after: avoid; }
table, figure { break-inside: avoid; }
}
@page {
size: A4;
margin: 16mm 14mm;
}
/* Use sparingly: ink-heavy pages are hard to read and expensive to print. */
* { -webkit-print-color-adjust: exact; }
The print-color adjustment rule asks Chromium to preserve declared colors instead of applying its normal print adjustments. Verify contrast and ink usage rather than applying it blindly. Keep headers with the following paragraph, prevent tables and figures from splitting where practical, and hide menus, cookie notices and controls that have no meaning in a PDF.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Paper size, margins and page ranges
Set format: 'A4' or 'Letter', or provide explicit dimensions. Margins in mm, cm, in and px make the intent clear. Puppeteer and Playwright also expose PDF options for landscape output and, where supported by the installed version, selecting page ranges. Keep CSS @page rules and API margins aligned; conflicting values make maintenance harder.
Wait for data, images and fonts
Use an application readiness signal
When a report fetches data after navigation, have the page expose a deterministic marker:
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.
await page.goto('file:///absolute/path/report.html', { waitUntil: 'networkidle2' });
await page.waitForSelector('[data-report-ready="true"]');
await page.pdf({ path: 'report.pdf', format: 'A4', printBackground: true });
For a page-defined promise, wait for that promise through the browser API. This is more reliable than an arbitrary sleep when charts or totals depend on asynchronous work. Puppeteer’s PDF operation waits for fonts by default, but fonts still need to be reachable and valid. Check image URLs, web-font responses and stylesheets from the same environment that runs Chromium.
Local-file security and paths
Use file:/// followed by a correctly escaped absolute path. A local document can reference files only where the browser process has access. If relative assets are troublesome, set the page content with a complete document and provide absolute asset URLs. Treat untrusted HTML as executable browser input: sanitize it or isolate the browser according to your threat model, and do not grant unnecessary filesystem or network access.
Deployment, reliability and cost controls
- Process lifecycle: always close pages and browsers in a
finallyblock so failed jobs do not leak Chromium processes. - Memory and concurrency: each browser/page consumes resources. Limit concurrent jobs, queue bursts and set job timeouts appropriate to your largest document.
- Containers: ensure the image contains the browser binaries, required fonts and shared-memory capacity. Sandbox settings are a deployment decision; do not disable security controls without understanding the isolation impact.
- Reproducibility: pin library and browser versions, use fixed paper settings and keep a representative document for regression checks.
- Observability: record navigation failures, console errors, missing assets and PDF generation duration without logging secrets or personal document contents.
Browser startup is relatively expensive. A controlled worker can reuse a browser while creating a fresh page per job; restart it on a policy or health threshold to contain leaks. Cache immutable assets where appropriate, but do not cache personalized HTML or credentials.
Troubleshooting common failures
The PDF is blank or missing sections
Usually the capture ran before client-side data arrived. Wait for a report-ready selector or promise, inspect console/network errors, and confirm the page does not require an interactive login.
Images, CSS or fonts are missing
Check every URL from the Chromium process, not your desktop browser. For local files, use absolute paths and verify permissions. For remote assets, inspect certificate, DNS, authentication and content-type errors. Missing fonts can produce fallback glyphs and changed line wrapping.
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
The layout differs from the browser
PDF generation uses print media by default. Add print-specific CSS, or explicitly emulate screen media if that is truly desired. Set paper size and margins in one documented place, then check for fixed-position elements and responsive breakpoints at the PDF viewport.
Colors look washed out
Printing may modify colors. Add -webkit-print-color-adjust: exact where exact reproduction matters, then review contrast and ink coverage on real output.
Navigation never finishes
Analytics, WebSockets or long-polling can prevent an idle condition. Use a bounded navigation timeout and an application readiness selector instead of waiting forever. Abort or report jobs that exceed your service’s maximum duration.
Chromium fails in production
Confirm that the browser binary and system dependencies are installed, the process user can launch it, and the container has enough memory. Check sandbox policy and shared-memory configuration before changing launch arguments.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
ScreenshotNeo provides a hosted website screenshot and PDF API. One GET request can render a URL as a PDF without packaging Chromium in your service. The API accepts many options, including paper size, margins, landscape mode and page ranges, plus waits for selectors, delays or network idle, custom headers/cookies, JavaScript, CSS, authentication, blocking rules and signed asynchronous webhooks.
Free tools Windows power users keep installed
One-click scans. No signup required.
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
For PDF output, add the PDF parameters documented at ScreenshotNeo’s documentation and use a PDF filename. Equivalent clients:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const bytes = new Uint8Array(await res.arrayBuffer());
Before capture, ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be disabled. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server lets Claude, Cursor and other MCP clients call take_screenshot, get_page_info and capture_pdf. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
FAQ
Can JavaScript convert an HTML string without creating a file?
Yes. Create a page, call page.setContent() with a complete document, wait for its assets or readiness marker, then call page.pdf(). Use absolute URLs for remote styles, images and fonts.
Which approach is safer for untrusted HTML?
Use sanitization and browser isolation appropriate to the threat model. HTML rendered by a headless browser can execute scripts and request resources, so restrict filesystem, network and credentials.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Why is a PDF pagination different from a screenshot?
A PDF lays out a document across paper pages using print media, margins and break rules. A screenshot is a bitmap viewport (or a tall image), so it does not apply paper pagination.
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.

