Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated 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 matchThe reliable way to convert a web page to PDF in TypeScript is to render the page in a real Chromium browser, wait for the content your application needs, and call the browser’s PDF API. Puppeteer and Playwright both support this workflow. The resulting PDF can be written directly to disk or returned as bytes from an API.
Use Puppeteer to generate a PDF
Install Puppeteer in a TypeScript project:
npm install puppeteer
npm install -D typescript tsx @types/node
Create convert.ts:
import puppeteer from 'puppeteer';
async function webPageToPdf(url: string, outputPath: string) {
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.goto(url, {
waitUntil: 'networkidle2',
timeout: 90_000
});
await page.pdf({
path: outputPath,
format: 'A4',
printBackground: true
});
} finally {
await browser.close();
}
}
webPageToPdf('https://example.com', 'example.pdf')
.catch((error) => {
console.error(error);
process.exitCode = 1;
});
Run it with npx tsx convert.ts. Puppeteer downloads a compatible browser during installation in the usual setup. In a deployment image, make sure the browser binary and its system dependencies are available.
Return PDF bytes instead of creating a file
Omit path and retain the returned value. Puppeteer returns PDF data that can be written with Node’s file APIs or sent as an HTTP response:
import puppeteer from 'puppeteer';
export async function pdfBytes(url: string): Promise<Uint8Array> {
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.goto(url, { waitUntil: 'networkidle2', timeout: 90_000 });
return await page.pdf({ format: 'A4', printBackground: true });
} finally {
await browser.close();
}
}
For an Express-style endpoint, set Content-Type: application/pdf, optionally set Content-Disposition, and send the returned bytes. Keep browser launch and page cleanup inside a try/finally so timeouts do not leave Chromium processes running.
#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.
Wait for the page you actually need
networkidle2 is a useful navigation example, not a universal definition of “finished.” Analytics, websockets, polling, advertisements and lazy components can keep a page active or can render after navigation settles.
Wait for a selector
await page.goto(url, { waitUntil: 'domcontentloaded' });
await page.waitForSelector('#article-content', { timeout: 30_000 });
await page.pdf({ path: 'article.pdf', format: 'A4' });
Wait for a known application state
await page.goto(url, { waitUntil: 'domcontentloaded' });
await page.waitForFunction(() => {
return document.querySelector('[data-render-state="ready"]') !== null;
}, { timeout: 30_000 });
Use a short fixed delay only when the page has no better readiness signal. A delay alone makes output slower and still may miss content on a busy connection.
Load lazy content before printing
For pages that load images only while scrolling, scroll through the document before calling page.pdf():
await page.evaluate(async () => {
await new Promise<void>((resolve) => {
let y = 0;
const step = 600;
const timer = setInterval(() => {
window.scrollBy(0, step);
y += step;
if (y >= document.body.scrollHeight) {
clearInterval(timer);
window.scrollTo(0, 0);
resolve();
}
}, 100);
});
});
Control print layout with CSS and PDF options
Both Puppeteer and Playwright use print CSS media by default. Add print-specific rules to the page or inject them from TypeScript:
await page.addStyleTag({ content: `
@page { size: A4; margin: 18mm 14mm; }
nav, .cookie-banner, .chat-widget { display: none !important; }
h1, h2, h3 { break-after: avoid; }
table, img, pre { break-inside: avoid; }
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
` });
Important options include:
- format: a standard paper size such as
A4orLetter. - width and height: explicit dimensions when a standard format is unsuitable.
- landscape: use
truefor wide tables or diagrams. - margin: top, right, bottom and left values.
- printBackground: set
truewhen colored sections or background images matter. - pageRanges: print selected pages, for example
1-3. - scale: adjust content size when it does not fit the selected paper.
- preferCSSPageSize: let an
@pagerule determine dimensions where supported. - displayHeaderFooter,
headerTemplateandfooterTemplate: add repeating PDF headers and footers where supported by your installed version.
If you want the screen design rather than print design, emulate screen media before generating the PDF:
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.emulateMediaType('screen');
await page.pdf({ path: 'screen-style.pdf', printBackground: true });
Print rendering can alter colors. The -webkit-print-color-adjust: exact declaration requests the page’s colors, but the final appearance still depends on browser and PDF viewer behavior.
Make fonts, authentication and navigation predictable
Fonts
Puppeteer’s PDF method waits for fonts by default in current versions. If a custom font is critical, explicitly wait for it:
await page.evaluate(async () => {
await document.fonts.ready;
});
A background page or a font blocked by credentials, CSP or network policy can still fall back to another font. Verify that the font request succeeds inside the browser.
Recommended Free Tools
Authenticated pages
Set cookies, HTTP headers or login state before navigation. Never place secrets in a URL that may be logged:
await page.setExtraHTTPHeaders({ Authorization: `Bearer ${process.env.API_TOKEN}` });
await page.goto('https://example.com/private-report', {
waitUntil: 'domcontentloaded',
timeout: 90_000
});
For a session cookie, use page.setCookie() with the correct domain, path, secure and expiry properties. Treat the generated PDF as sensitive data and delete temporary files when they are no longer needed.
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.
Navigation failures
Use an explicit timeout and inspect the navigation result. A page can return an HTTP error while still producing HTML, so decide whether your application should reject non-success status codes.
const response = await page.goto(url, {
waitUntil: 'domcontentloaded',
timeout: 90_000
});
if (!response || !response.ok()) {
throw new Error(`Navigation failed: ${response?.status() ?? 'no response'}`);
}
Playwright alternative
If your project already uses Playwright, its page-level PDF API follows the same model and returns PDF data. A minimal implementation is:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsimport { chromium } from 'playwright';
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com', {
waitUntil: 'networkidle',
timeout: 90_000
});
const pdf = await page.pdf({
format: 'A4',
printBackground: true
});
await Bun.write('example.pdf', pdf);
} finally {
await browser.close();
}
With Node.js, use writeFile('example.pdf', pdf) from node:fs/promises instead of Bun.write. Choose the library already used by your tests or browser automation; the documented PDF behavior is similar, but option names and defaults depend on the installed version.
Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Blank or nearly empty PDF | JavaScript content was not ready, or the wrong frame was printed. | Wait for a page-specific selector or ready flag; confirm the URL and frame. |
| Images missing | Lazy loading, blocked requests or cross-origin failures. | Scroll to trigger lazy images, wait for image completion, and inspect browser console/request errors. |
| Wrong colors or no backgrounds | Print media rules or disabled background printing. | Set printBackground: true, add print color adjustment, or emulate screen media. |
| Content clipped | Margins, scale, fixed widths or an unsuitable paper orientation. | Use CSS @page, landscape mode, a smaller scale or responsive print rules. |
| Timeout during navigation | Long polling, slow assets, bot checks or an unreachable host. | Use a readiness condition instead of network idle, increase the timeout only when justified, and log the failing URL. |
| Browser will not launch in production | Missing Chromium executable or Linux libraries. | Install the browser and OS dependencies in the image, or configure the executable path explicitly. |
| Fonts differ from the browser preview | Font requests failed or completed after capture. | Check font responses, wait for document.fonts.ready, and ensure the same fonts are available in deployment. |
Performance, reliability and cost considerations
Launching a new browser for every request is simple but expensive at scale. A worker can reuse one browser and create isolated pages, while still closing each page in a finally block. Limit concurrency so memory use does not grow without bound. Set navigation and PDF timeouts, record URL and status diagnostics, and retry only transient failures; repeated retries will not fix a deterministic layout or authentication error.
Cache PDFs when the source URL and relevant inputs have not changed. For untrusted URLs, restrict outbound network access and prevent access to internal services. Validate allowed schemes, enforce maximum document size and consider request-level cancellation. The PDF contains whatever the browser can access, including private data.
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
Or skip the browser setup
ScreenshotNeo provides a hosted screenshot and PDF endpoint when you do not want to package Chromium. One GET request returns a PDF or image; its capture options include paper size, margins, landscape mode and page ranges. Cookie and consent banners, newsletter popups and chat widgets are removed before the shot. 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 server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.
Free tools Windows power users keep installed
One-click scans. No signup required.
See the ScreenshotNeo API documentation for authentication and the complete option list.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
For a PDF, request the PDF output according to the API documentation. The same endpoint also supports custom CSS and JavaScript, selectors, device and viewport settings, headers, cookies, authorization, geolocation, time zones, caching, asynchronous jobs and bulk capture.
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)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account to try it.
FAQ
Can TypeScript convert HTML strings rather than URLs?
Yes. Open a page, call page.setContent(html), wait for required assets or selectors, and then call page.pdf(). External images and fonts must still be reachable by the browser.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Does PDF generation require a visible desktop browser?
No. Puppeteer and Playwright normally run Chromium headlessly. A server still needs the browser executable and its operating-system dependencies.
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.
Which library should a new project choose?
Use the library that matches your existing automation, test fixtures and deployment image. Both expose browser-rendered PDF generation; there is no documented performance comparison here.
Frequently Asked Questions
Can TypeScript convert HTML strings rather than URLs?
Yes. Use page.setContent(), wait for required assets or selectors, then call page.pdf().
Does PDF generation require a visible desktop browser?
No. Puppeteer and Playwright normally run Chromium headlessly, provided the browser and system dependencies are installed.
Which library should a new project choose?
Prefer the library already used by your automation and deployment stack; both support browser-rendered PDFs.
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.

