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 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteThe most controllable way to generate a PDF from a web page is to render the page in a real browser and call Playwright’s page.pdf(). It returns a PDF buffer, uses print CSS media by default, and lets you set paper size, margins, backgrounds, headers, footers, page ranges and scale. If you do not want to operate browsers, use a managed rendering or document-conversion API instead.
This guide shows both approaches, explains the differences between a URL and supplied HTML, and covers layout, reliability, security, troubleshooting and cost questions that affect production systems.
Choose the right PDF generation route
Start with the input you actually have:
| Input or requirement | Best-fit route | Why |
|---|---|---|
| A public or authenticated web page whose JavaScript must run | Playwright or a hosted browser-rendering API | A browser waits for scripts, fonts, images and other resources before printing. |
| An HTML template your application already owns | Playwright page.setContent() or an HTML-to-PDF service |
You can print the generated markup without publishing it first. |
| Packaged static or dynamic HTML, or a ZIP of assets | A document-conversion API such as Adobe PDF Services | Adobe documents HTML, ZIP and URL inputs for its HTML-to-PDF operation. |
| Workers-based deployment | Cloudflare Browser Rendering | Cloudflare documents a PDF endpoint callable through REST or Workers bindings, accepting a URL or HTML. |
| Maximum rendering and deployment control | Your own Playwright workers | You choose browser version, network policy, fonts, concurrency and storage. |
Prices, quotas, regional availability and retention policies change. Verify current terms directly with each provider before committing production traffic. A vendor’s claim about an unauthenticated service is not proof of its security, uptime or limits.
Generate a PDF with Playwright
Playwright’s PDF API runs in Chromium, renders the page, and returns a buffer. The default is print media, so a site’s print stylesheet can intentionally hide navigation or change layout. To preserve screen styles, emulate screen before calling page.pdf().
#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.
Install and create a minimal Node.js service
- Install Node.js and create a project:
mkdir web-pdf && cd web-pdf && npm init -y. - Install Playwright:
npm install playwright. - Download the browser used by your installed package:
npx playwright install chromium. - Save the following as
generate-pdf.mjs.
import { chromium } from 'playwright';
import { writeFile } from 'node:fs/promises';
const target = process.argv[2] ?? 'https://example.com';
const browser = await chromium.launch();
try {
const page = await browser.newPage({
viewport: { width: 1440, height: 900 },
deviceScaleFactor: 1
});
await page.goto(target, { waitUntil: 'networkidle', timeout: 90_000 });
await page.emulateMedia({ media: 'print' });
const pdf = await page.pdf({
format: 'A4',
printBackground: true,
margin: { top: '18mm', right: '15mm', bottom: '18mm', left: '15mm' },
displayHeaderFooter: true,
headerTemplate: '',
footerTemplate: ' / ',
preferCSSPageSize: true,
scale: 1
});
await writeFile('page.pdf', pdf);
} finally {
await browser.close();
}
Run it with node generate-pdf.mjs https://example.com. The output is page.pdf. In an HTTP handler, send the same buffer with Content-Type: application/pdf and a suitable Content-Disposition header instead of writing it to disk.
Print supplied HTML instead of a URL
import { chromium } from 'playwright';
import { writeFile } from 'node:fs/promises';
const html = `
Invoice 1042
Amount due: $125.00`;
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.setContent(html, { waitUntil: 'load' });
const pdf = await page.pdf({ format: 'A4', printBackground: true, preferCSSPageSize: true });
await writeFile('invoice.pdf', pdf);
} finally {
await browser.close();
}
Control print layout with CSS and PDF options
Print versus screen media
Use print media when the site has a deliberate print stylesheet. Use await page.emulateMedia({ media: 'screen' }) when the PDF should resemble the on-screen page. Printing can alter colors; add -webkit-print-color-adjust: exact to relevant elements when preserving exact colors matters, while recognizing that a browser or printer may still apply its own constraints.
Paper size, margins and CSS page size
format: 'A4' or format: 'Letter' is convenient for standard paper. You can instead provide explicit width and height. margin accepts top, right, bottom and left values. Set preferCSSPageSize: true when the document’s @page rule must take precedence over the API’s format or dimensions.
Backgrounds, page ranges and scale
printBackground: trueincludes background colors and images; without it, branded sections may appear white.pageRanges: '1-3'exports selected pages when you do not need the entire document.scalechanges the rendered size. Test carefully because scaling can create unexpectedly small text or additional page breaks.
Headers and footers
Set displayHeaderFooter: true and provide HTML templates. Playwright supplies placeholders such as pageNumber and totalPages. Header and footer templates have limited styling and do not behave like ordinary page content; keep them simple.
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.
Page-break rules
Use CSS to keep logical blocks together: break-inside: avoid, break-before: page and break-after: avoid. Define repeatable table headers with thead { display: table-header-group; }. Always test long rows, images and nested flex or grid layouts because a browser may move an item to the next page when it cannot fit.
Wait for the page to be genuinely ready
networkidle is useful but not a guarantee that a chart, web font or lazy image is visually complete. Add an explicit readiness signal in your application:
await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 90_000 });
await page.waitForSelector('[data-pdf-ready="true"]', { timeout: 30_000 });
await page.evaluate(() => document.fonts.ready);
await page.evaluate(() => Promise.all(
[...document.images].map(img => img.complete ? Promise.resolve() : new Promise(resolve => {
img.addEventListener('load', resolve, { once: true });
img.addEventListener('error', resolve, { once: true });
}))
));
const pdf = await page.pdf({ format: 'A4', printBackground: true });
Have the page set data-pdf-ready only after data fetching and client-side rendering finish. For very long pages, prefer paginated HTML over relying on one enormous canvas or image.
Expose PDF generation as an API endpoint
A production endpoint should validate the target, enforce an allowlist where possible, apply authentication and rate limits, and return a stable response. A minimal Express-style handler looks like this:
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 →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.
import express from 'express';
import { chromium } from 'playwright';
const app = express();
const browserPromise = chromium.launch();
app.get('/pdf', async (req, res) => {
const url = String(req.query.url || '');
if (!/^https:///i.test(url)) return res.status(400).json({ error: 'An HTTPS URL is required' });
const browser = await browserPromise;
const page = await browser.newPage();
try {
await page.goto(url, { waitUntil: 'networkidle', timeout: 90_000 });
const pdf = await page.pdf({ format: 'A4', printBackground: true });
res.type('application/pdf').set('Content-Disposition', 'inline; filename="page.pdf"').send(pdf);
} catch (error) {
res.status(502).json({ error: 'Page could not be rendered' });
} finally {
await page.close();
}
});
app.listen(3000);
Do not let an unrestricted service fetch arbitrary internal addresses. Block loopback, private-network and cloud-metadata destinations after DNS resolution, limit redirects, restrict outbound protocols to HTTPS, cap navigation time and close every page in a finally block. Treat cookies, authorization headers and generated PDFs as sensitive data.
Managed API alternatives
Cloudflare Browser Rendering
Cloudflare documents a /pdf endpoint that accepts either url or html. It can be called through REST with a Browser Rendering edit token or through Workers bindings. This is a practical fit when your application already runs on Workers and you prefer not to package Chromium yourself.
Adobe PDF Services
Adobe documents HTML-to-PDF conversion for static and dynamic HTML, ZIP packages and URLs. Its example uses an API key and bearer authorization. Check the current request limits, supported assets and data-handling terms for your region before sending customer documents.
PDFSpark and similar vendors
PDFSpark’s documentation describes POST routes for raw HTML and URL conversion and claims that authentication or signup is unnecessary. That is vendor-authored information, not independent evidence. Evaluate its security model, reliability, retention, limits and current terms before using it for sensitive or high-volume workloads.
Free tools Windows power users keep installed
One-click scans. No signup required.
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
Performance, reliability and cost decisions
Run browsers efficiently
- Keep one browser process and create short-lived pages; launching Chromium for every request adds avoidable latency.
- Use a bounded queue so concurrent jobs do not exhaust CPU or memory.
- Reuse cached, immutable assets and avoid waiting for third-party analytics that do not affect the PDF.
- Set separate navigation and total-job timeouts, then record the URL, duration, browser version and failure stage.
Make output reproducible
Pin the Playwright package and browser revision, install the same fonts in every environment, and test representative pages after upgrades. Store a content hash or template version with each generated document. A font fallback or changed remote image can alter pagination without changing your code.
Estimate operating cost
Self-hosting shifts cost to compute, memory, browser maintenance, observability and on-call work. Hosted APIs shift those costs to provider pricing and quotas. Comparable current prices and limits for the services above are not established here, so obtain a written, current quote or plan specification before forecasting a unit cost.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot common failures
| Symptom | Likely cause | Fix |
|---|---|---|
| Blank or partly rendered PDF | JavaScript or lazy content had not finished. | Wait for a readiness selector, fonts and images; increase the timeout only after adding a deterministic signal. |
| Colors or backgrounds are missing | Print media or background printing changed the design. | Try screen media, set printBackground: true, and use print-color adjustment where exact colors are required. |
| Wrong paper dimensions | An @page rule overrides API settings. |
Choose whether CSS or API controls size, then set preferCSSPageSize consistently. |
| Content overlaps the footer | CSS content reaches the printable edge or margins are too small. | Increase bottom margin, reserve footer space and inspect page-break rules. |
| Fonts differ between environments | The required font is absent or a remote font failed. | Install and pin fonts, wait for document.fonts.ready, or bundle approved font files. |
| Navigation timeout | Third-party resources, bot protection or a slow origin blocked readiness. | Capture a trace or screenshot, remove nonessential dependencies, allow the required domains and return a clear 502/504 response. |
| Server becomes unstable under load | Too many Chromium pages or unbounded jobs. | Use a queue, cap concurrency, monitor memory and recycle workers deliberately. |
Or skip the browser setup
ScreenshotNeo is the first alternative to try when you want a hosted capture API: it accepts a URL and can return a PNG, JPEG, WebP or PDF, while removing cookie-consent banners, newsletter popups and chat widgets before capture. Only clean shots are billed; bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and each response identifies the page verdict and billing status.
For a one-call request, see the ScreenshotNeo API documentation:
Recommended Free Tools
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The same endpoint also supports PDF output; consult the current format options in the documentation. ScreenshotNeo includes an MCP server with take_screenshot, get_page_info and capture_pdf tools, so Claude, Cursor and other MCP clients can request captures. Every plan includes the features; 1,000 screenshots per month are free with no card, and paid plans start at $5 for 3,000 shots. Sign up for the free plan.
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.
Python and Node.js client examples for ScreenshotNeo
Python
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)
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}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
Frequently Asked Questions
Can an API generate a PDF from a page that requires login?
Yes, if the renderer can authenticate safely. With Playwright, use an isolated browser context and inject only the required cookies or authorization headers; never expose those credentials in a client-visible URL.
Should I generate a PDF in the browser or on my server?
Generate it on a controlled server or worker. Browser-side generation exposes implementation details, varies by the reader’s device and cannot reliably protect private source content.
How do I test that a PDF is accessible?
Inspect text order, tagged structure, keyboard reading order, contrast and link targets with an accessibility checker, then review the rendered pages at normal zoom. Visual correctness alone does not prove accessibility.
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.

