Free tools Windows power users keep installed
One-click scans. No signup required.
Use a headless browser to render your HTML and CSS, call Puppeteer’s or Playwright’s page.pdf(), then send the returned bytes from an Express route with the application/pdf content type. For reliability, reuse a browser process when appropriate, create and close a page per request, wait for critical assets, and set timeouts and concurrency limits for your deployment. One important visual detail: PDF generation uses print CSS by default, not screen CSS.
Choose a rendering approach
For modern HTML and CSS, a headless browser is the practical default: it renders the page with a browser engine, then produces PDF bytes. Puppeteer and Playwright both expose page-level PDF generation. Neither is universally better for this task; choose based on your runtime packaging, deployment environment, existing test stack, API conventions, and the PDF options your document needs.
- Puppeteer: Its documentation directs developers to
Page.pdf()for printing PDFs. It documents waiting for fonts by default during PDF generation. - Playwright: Its Page API documents
page.pdf()as returning a PDF buffer and provides an API to emulate screen media.
The examples below use Puppeteer. They show one reasonable implementation pattern, not a claim that a particular deployment has been tested. The same route shape works with Playwright, with library-specific setup and page APIs.
Build an Express PDF endpoint with Puppeteer
Install the dependencies
In an existing Node.js project, install Express and Puppeteer:
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →#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.
npm install express puppeteer
Puppeteer launches a browser for rendering. Confirm that the browser can be installed and run in your deployment environment; serverless platforms, containers, and restricted hosts can have different runtime requirements.
Create the route
This example accepts a URL identifying a report page, navigates to it, waits for network activity to settle, generates an A4 PDF, and returns the PDF buffer. In production, do not pass arbitrary user-controlled URLs through to the browser; the security section explains why.
const express = require('express');
const puppeteer = require('puppeteer');
const app = express();
let browser;
async function getBrowser() {
if (!browser || !browser.connected) {
browser = await puppeteer.launch({ headless: true });
}
return browser;
}
app.get('/report.pdf', async (req, res, next) => {
let page;
try {
const target = new URL(req.query.url);
// Replace this example allowlist with the origins your app needs.
const allowedOrigins = new Set(['https://reports.example.com']);
if (!allowedOrigins.has(target.origin)) {
return res.status(400).send('URL origin is not allowed');
}
const browser = await getBrowser();
page = await browser.newPage();
page.setDefaultNavigationTimeout(30_000);
page.setDefaultTimeout(30_000);
await page.goto(target.href, { waitUntil: 'networkidle2' });
const pdf = await page.pdf({
format: 'A4',
printBackground: true
});
res.type('application/pdf').send(pdf);
} catch (error) {
next(error);
} finally {
if (page) {
await page.close().catch(() => {});
}
}
});
app.listen(3000, () => {
console.log('PDF service listening on port 3000');
});
Start the server, then request /report.pdf with a URL on the configured allowed origin. Express’s res.send() accepts a Buffer; res.type('application/pdf') sets the response MIME type so clients can identify the response as a PDF.
The example keeps the browser process warm and creates a new page for each request. It closes the page in finally, including when navigation or PDF generation fails. If your service shuts down gracefully, close the browser process as part of its shutdown handling. Reuse reduces repeated browser startup overhead, but it does not establish a safe request capacity: measure your workload and set a concurrency limit appropriate to your host.
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.
Render HTML held by your application
If the report is generated from a trusted template rather than an existing URL, use page.setContent() instead of navigating to a URL. For example, replace the page.goto() line with:
await page.setContent(renderReportHtml(req.query), {
waitUntil: 'networkidle'
});
renderReportHtml() should escape or safely encode user-provided values and return a complete HTML document. Do not interpolate untrusted strings into executable markup or scripts.
Control print styling, page breaks, and colors
Puppeteer’s PDF generation uses the print CSS media type by default. That means a page can look different in a PDF than it does in a normal browser window: print styles may change layout, hide controls, or alter colors. Playwright has the same print-media default.
Make a deliberate media choice
For a document designed to be printed or saved, keep print media and write print-specific CSS. If the PDF should follow screen styles, switch media before calling page.pdf():
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.emulateMediaType('screen');
const pdf = await page.pdf({ format: 'A4', printBackground: true });
With Playwright, the corresponding choice is to use its page.emulateMedia() API. Do not assume a screen-looking page automatically produces a screen-faithful PDF; verify the rendered output.
Add document-specific print rules
Put page layout rules in the document’s stylesheet. For example, use print media rules to hide interactive controls and prevent a heading from being separated from its content:
@media print {
.interactive-controls {
display: none;
}
h1, h2 {
break-after: avoid;
}
.new-page {
break-before: page;
}
}
Set PDF margins in the PDF options when those are a document-level setting, and use CSS page rules where page-specific layout belongs. Check long tables, oversized images, and sections that may split across pages. A layout that fits a browser viewport may overflow, break awkwardly, or produce extra pages when printed.
Preserve colors and backgrounds intentionally
Printed colors may be modified by default. Puppeteer’s Page.pdf reference recommends -webkit-print-color-adjust when exact colors are needed. Add it selectively where the design depends on color, and retain printBackground: true when backgrounds should appear in the PDF:
Recommended Free Tools
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
@media print {
.brand-color {
-webkit-print-color-adjust: exact;
}
}
Test colors, fonts, images, and page breaks in the same kind of environment that will serve the document. Browser version, font availability, external asset access, and print styles can all affect the result.
Wait for fonts and important assets
Puppeteer documents that Page.pdf() waits for fonts to load by default. That helps with web fonts, but your document can still fail to match expectations if a font or image is unavailable, blocked, or slow. For critical images, you can explicitly wait until image elements have completed loading before generating the PDF:
await page.evaluate(async () => {
const images = Array.from(document.images);
await Promise.all(images.map((image) => {
if (image.complete) return Promise.resolve();
return new Promise((resolve) => {
image.addEventListener('load', resolve, { once: true });
image.addEventListener('error', resolve, { once: true });
});
}));
});
This waits for each image to either load or fail; it does not make a failed image valid. If assets are essential, record or check failures and decide whether to reject the document or render with missing assets. Use bounded navigation and rendering timeouts so an unavailable font, image, or page cannot hold a request indefinitely.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Secure and operate the endpoint
Treat URLs and markup as a security boundary
A browser rendering a user-supplied URL can make server-side network requests. Restrict navigation to approved origins, validate template data, and do not let untrusted markup trigger requests to internal services or other unintended destinations. An origin allowlist is a starting point, not a complete security model for every application.
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.
If clients can submit HTML, keep it isolated from privileged application data and avoid executing user-controlled scripts. Consider which outbound resources the browser may load, and enforce network restrictions at the infrastructure layer where appropriate.
Limit public access and expensive work
PDF rendering consumes browser and server resources. For a public endpoint, use authentication, rate limits, request-size limits, and queueing where needed. Set a maximum number of concurrent renders based on measurement rather than a guessed universal value. Ensure every path closes its page; otherwise failed or slow work can accumulate browser resources.
Measure before setting capacity
The cited official library documentation does not publish a universal throughput or memory figure for this kind of endpoint. Test representative templates in the target environment, including the actual fonts, asset sizes, browser version, and concurrency. Track render duration, failures, timeouts, and resource use; tune queue depth and concurrency from those observations.
Troubleshoot common PDF problems
- The PDF differs from the browser page: PDF output defaults to print media. Inspect
@media printrules and decide whether the document should use print styling or emulate screen media. - Background colors are missing: Check that
printBackground: trueis set. For colors that must remain exact, apply-webkit-print-color-adjustin print CSS. - A web font or image is missing: Check that the browser can reach the asset and that the URL is valid in the deployed environment. Wait for required assets before PDF generation, and handle failed assets explicitly rather than waiting without a bound.
- The request hangs or fails on slow pages: Set navigation and rendering timeouts, identify which external asset or page request is slow, and avoid waiting indefinitely for all network activity. Choose a wait condition that suits the page’s behavior.
- The endpoint returns an error after a render failure: Pass failures to Express error middleware with
next(error), and close the page in afinallyblock. Log enough context to diagnose the failed job without exposing sensitive document contents. - The host cannot launch the browser: Check browser installation and runtime compatibility for the actual container or hosting platform. Browser packaging and launch requirements are deployment-specific; do not assume a local development setup will behave identically in production.
- Capacity drops under concurrent requests: Measure memory and render duration with representative documents, then cap concurrency or queue jobs. Reusing a browser can reduce startup overhead, but does not remove per-page rendering costs.
Or skip the browser setup
If your goal is to capture a public web page rather than render a custom application template, ScreenshotNeo offers a screenshot API and MCP server. It can return a clean screenshot or PDF, but the example below is the supplied image-capture call and saves a WebP image; consult the ScreenshotNeo documentation for PDF-specific request options.
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 →curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie and consent banners before capture and removes known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers indicate the page verdict and billing status. Its MCP server provides screenshot tools for AI agents. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. If that fits your use case, sign up for the free plan.
Frequently asked questions
Can I generate a PDF without saving it to disk?
Yes. The page-level PDF method returns bytes that you can send directly as a response Buffer, as in the Express example; a file path is not required for that pattern.
Should I use a URL or set the HTML directly?
Navigate to a URL when the page already exists and is accessible to the rendering browser. Use page.setContent() when your application creates the document HTML from a controlled template.
Is there a standard number of PDF requests one browser can handle?
No universal throughput or memory figure is established by the cited official documentation. Measure your templates and deployment environment before choosing concurrency.
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.

