To export HTML to PDF, use your browser’s print dialog for a one-off file, Puppeteer or Playwright for repeatable code, or an HTML-to-PDF API when you want a managed service. The important quality controls are print CSS, page size and margins, background graphics, and waiting for dynamic content before rendering.
Choose the right HTML-to-PDF workflow
| Situation | Best fit | What you control |
|---|---|---|
| Save one page occasionally | Browser print workflow | Preview, destination, basic paper and margin settings |
| Generate PDFs in an application or CI job | Puppeteer or Playwright | Browser version, CSS media, paper, margins, page ranges, backgrounds, waits and scripts |
| Convert URLs or uploaded HTML without operating a browser | Hosted HTML-to-PDF API | Service job settings, readiness selector and synchronous or asynchronous processing |
There is no single universal menu path: browser labels vary by operating system and edition. In any browser, open the page, invoke its print command, choose a PDF destination, inspect the preview, and save. If the preview is wrong, fix the page’s print CSS or use a programmable renderer.
Prepare HTML for reliable PDF output
Use print-specific CSS
CSS can deliberately produce a different printed document. An @media print block can hide navigation, remove interactive controls and adjust typography. The @page at-rule can set page margins and other printed-page properties. See MDN’s printing guidance.
@media print {
nav, .cookie-banner, .no-print { display: none !important; }
a { color: #000; text-decoration: none; }
}
@page {
size: A4;
margin: 16mm 14mm;
}
Inspect the result rather than assuming every browser honors every rule identically. Long tables, positioned elements and very large images are common sources of unexpected page breaks.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- Engineered for convenience – This new Brother Monochrome Laser Printer is conveniently equipped with a flatbed scan glass for quick copying and scanning. Mobile Device Compatibility AirPrint, Google Cloud Print 2.0, Brother iPrint and Scan, Mopria, Cortado Workplace
- Optimized for efficiency – Engineered with new features, the HL L2395DW laser printer (replacement for the HLL2380DW) and has been optimized for efficiency, allowing you to print up to 36 pages per minute(1)
- Faster, high quality prints: This monochrome laser printer is built with a 250 sheet paper capacity that helps improve efficiency due to less time spent refilling trays. It also handles both letter and legal sized paper. Power Source AC 120V 50/60Hz.Machine Noise (Ready/Printing): 30dB / 50dB
- Cloud based print & scan – Print from and scan to popular Cloud services directly from the 2.7" color touchscreen, including Dropbox, Google Drive, Evernote, OneNote, and more(4)
- Wireless printing & exceptional support – This printer’s simple to connect wireless technology allows you to submit print jobs from your laptop, smartphone, desktop, and tablets(2). The "Touch to connect" printing with NFC delivers added convenience(3).
Decide whether print or screen styling is wanted
Puppeteer’s Page.pdf() and Playwright’s page.pdf() use the print CSS media type by default. If the PDF should match the screen layout, explicitly emulate screen media before generating it. Print rendering may also alter colors; background graphics are optional and are not enabled by default in the documented APIs.
Make asynchronous content ready
Wait for navigation, fonts and content that appears after JavaScript runs. A selector that proves the main report has rendered is usually more reliable than an arbitrary short delay. Images loaded lazily may need scrolling or an application-specific readiness signal.
Export HTML to PDF from a browser
- Open the URL or local HTML file.
- Run the browser’s print command.
- Select the PDF destination in the print dialog.
- Review paper size, orientation, margins, scale, headers and footers, and background graphics.
- Check page breaks and links in the preview, then save the file.
This method is appropriate when a person can verify the preview. It is less suitable for scheduled exports because dialog controls, browser profiles and manual review do not form a deterministic pipeline.
Generate a PDF with Puppeteer
Install Puppeteer in a Node.js project with npm install puppeteer. The following script opens a URL, waits for network activity and fonts, and writes a PDF. Puppeteer documents the options in its Page.pdf() reference.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsconst puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com/report', { waitUntil: 'networkidle0' });
await page.pdf({
path: 'report.pdf',
format: 'A4',
printBackground: true,
margin: { top: '16mm', right: '14mm', bottom: '16mm', left: '14mm' },
waitForFonts: true,
preferCSSPageSize: true
});
await browser.close();
})();
The documented controls include paper format or explicit dimensions, margins, page ranges, printBackground, preferCSSPageSize and waitForFonts (font waiting defaults to true). To render the screen design instead of print CSS, add this before page.pdf():
await page.emulateMediaType('screen');
Useful Puppeteer adjustments
- Use
pageRangesfor selected pages. - Use
landscape: truefor wide reports. - Set
widthandheightwhen a named paper format is not appropriate. - Keep
preferCSSPageSize: truewhen the document’s@pagerule should control dimensions. - Wait for an application signal, such as
page.waitForSelector('#report-ready'), when data arrives after navigation.
Generate a PDF with Playwright
Install Playwright with npm install playwright and install its browser binaries according to the project’s setup instructions. Playwright’s Page API documents PDF generation and media emulation.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com/report', { waitUntil: 'networkidle' });
await page.waitForSelector('#report-ready');
await page.pdf({
path: 'report.pdf',
format: 'A4',
printBackground: true,
margin: { top: '16mm', right: '14mm', bottom: '16mm', left: '14mm' },
preferCSSPageSize: true
});
await browser.close();
})();
Playwright also defaults to print media. To request screen media, call:
Rank #2
- FAST PRINT AND SCAN: The Brother MFC-L3710CW lets you get things done with up to 19 ppm print speed and scans up to 29 ipm in black and 22 ipm in color
- AFFORDABLE AND FLEXIBLE COLOR PRINTING: Affordably print professional quality, rich, vivid color documents with laser printer quality. The 250 sheet adjustable paper tray helps minimize refills and the manual feed slot handles varied printing needs
- 3.7” COLOR TOUCHSCREEN: Print from and scan to popular cloud apps directly from the 3.7" color touchscreen including Dropbox, Google Drive, Evernote, OneNote and more. Save time by creating custom shortcuts on the touchscreen for your most used features.
- PRINT AND CONNECT YOUR WAY: Print wirelessly from your desktop, laptop, smartphone and tablet with built-in wireless, and Wi-Fi Direct or connect locally to a single computer via USB interface.
- UNIT DIMENSIONS (WxDxH): 16.1” W x 18.7” D x 16.3” H
await page.emulateMedia({ media: 'screen' });
Its PDF options cover format, margins, page ranges, backgrounds and CSS page-size preference. The API notes that print color adjustments can change the appearance from the screen view, so compare a generated file with the original page.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Use a hosted HTML-to-PDF API
A managed service can accept a URL or HTML file, apply page settings and return a PDF without your application maintaining browser binaries. CloudConvert documents URL and HTML inputs, custom CSS-selector waits, page size and margin controls, and synchronous or asynchronous jobs. Its website-capture operation is described at HTML to PDF API and Capture Website. Treat the service’s current documentation as authoritative for authentication, limits and pricing.
For any hosted converter, verify how it handles authenticated pages, external fonts, JavaScript, cookies, redirects, robots controls and private network addresses before sending production documents. A selector wait confirms that an element exists; it does not prove that every image or chart has finished rendering.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server that can return a PDF from one GET request. Before capture it accepts the cookie or consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Only clean shots are billed: bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits cost nothing, and response headers identify the page verdict and billing status.
Its 63 options include full-page capture with lazy images loaded, CSS-selector element capture, custom CSS and JavaScript, clicks, selector or network-idle waits, blocked requests and resource types, headers, cookies, user agents, authorization, timezone, geolocation, paper size, margins, landscape mode and page ranges for PDFs. It also supports asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, caching with a chosen TTL, signed image links, usage reporting, an OpenAPI specification and an MCP server with take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.
Recommended Free Tools
Use the API documentation at screenshotneo.com/docs/ for authentication and the complete parameter list.
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 can be called from 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)
Or 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}`);
ScreenshotNeo’s Free plan includes 1,000 shots per month without a card. Paid plans start at $5 for 3,000 shots; yearly billing provides two months free, and every feature is included on every plan. Sign up for the free plan to try it.
PDF settings that most affect the result
Paper, dimensions and margins
Choose a named format such as A4 or Letter when the audience expects standard paper. Use explicit width and height for labels, receipts or other fixed canvases. Margins consume usable width and can force an otherwise single-line heading onto two lines.
Rank #3
- Create a mix using audio, music and voice tracks and recordings.
- Customize your tracks with amazing effects and helpful editing tools.
- Use tools like the Beat Maker and Midi Creator.
- Work efficiently by using Bookmarks and tools like Effect Chain, which allow you to apply multiple effects at a time
- Use one of the many other NCH multimedia applications that are integrated with MixPad.
Backgrounds and color
Enable background printing when the document depends on colored panels, charts or images. Without it, a PDF can be technically complete but visually different from the page. Check color-sensitive documents on the intended printer or viewer.
Page ranges and breaks
Use page ranges to export only selected pages. Add deliberate break rules for sections when supported by your target browser, and test long tables: a row that cannot split may move to the next page or overflow.
Security and privacy
Do not expose secrets in query strings or page source. For private pages, use controlled headers or cookies, redact sensitive data before conversion, and restrict which URLs a server-side converter may fetch to prevent unintended internal-network access.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshooting HTML-to-PDF exports
Fonts are missing or layout shifts
Wait for fonts before calling PDF generation, verify that font files are reachable from the rendering environment, and avoid relying on a local desktop font that is absent in CI.
Charts or images are blank
Wait for a page-specific ready selector, ensure image URLs are accessible, and allow enough time for JavaScript chart rendering. A generic network-idle condition may finish before a timer-driven chart is drawn.
The PDF is missing colors or backgrounds
Enable printBackground (or the equivalent browser setting) and inspect print CSS for rules that intentionally remove color.
The PDF uses the wrong layout
Remember that print media is the default in Puppeteer and Playwright. Use screen media emulation only when the screen design is the desired output, then check page size and overflow.
Rank #4
- Save money by using PDF Fusion to view over 100 file formats without having to purchase additional software
- Merge incompatible files quickly and easily by dragging and dropping in PDF Fusion to create a new PDF documents
- Save time with PDF Fusion's editing tools to reuse the content from existing documents without starting from scratch
Content is cut off or pages are unexpectedly long
Check viewport and paper dimensions, margins, fixed-position elements and oversized images. Prefer CSS page sizing when the document defines an intentional @page size.
A hosted job never completes
Confirm the URL is publicly reachable by the service, authentication is configured, and the readiness selector actually appears. For asynchronous APIs, persist the job identifier and process the documented completion webhook or status response.
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 & 11Operational checklist
- Define whether the output should use print or screen media.
- Add and test
@media printand@pagerules. - Choose paper, dimensions, margins, orientation and page ranges.
- Enable backgrounds when visual fidelity requires them.
- Wait for fonts and application-specific content readiness.
- Test external assets, links, tables and page breaks in the final PDF viewer.
- Protect credentials and restrict server-side URL fetching.
- For repeated jobs, pin browser versions or document the hosted service configuration.
Frequently asked questions
Does exporting HTML to PDF preserve hyperlinks?
Browser and automation renderers generally create link annotations, but the exact behavior can vary with the page and renderer. Open the generated file and test representative links before distributing it.
Should I choose Puppeteer or Playwright?
Both documented APIs generate PDFs with print media by default and expose comparable page, margin, background and media controls. Choose based on the browser automation stack, test coverage and operational conventions already used by your project.
Can I export a local HTML file?
Yes, a browser can print a local file, and automation can navigate to a local file URL when the runtime permits it. Local pages may still fail to load remote fonts, images or scripts because of file-origin and network restrictions.
The Bottom Line
Use browser printing for a one-off export, Puppeteer or Playwright for deterministic application code, and a hosted API when you prefer managed conversion. In every case, treat print CSS, readiness waits and PDF page settings as part of the document—not as afterthoughts.
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.

