DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
Chrome Headless

How to Convert HTML to PDF from the Windows Command Line

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fastest browser-based method: run Chrome in headless mode with --print-to-pdf. For example:

chrome --headless --print-to-pdf https://developer.chrome.com/

Chrome writes output.pdf to the current directory. Add --no-pdf-header-footer for a cleaner document. This guide covers web URLs, local HTML files, repeatable scripts, alternative Windows renderers, security, troubleshooting, and an API option when you do not want to manage a browser installation.

1. Convert a web page with Chrome Headless

Install Chrome on Windows and make sure the executable is available as chrome in your command prompt. Open Command Prompt or PowerShell, change to the folder where you want the PDF, and run:

chrome --headless --print-to-pdf https://developer.chrome.com/

The result is output.pdf in the current working directory. The input can be any URL that Chrome can load. Chrome prints the page using browser print rendering, so screen CSS and print CSS can produce different results.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall

Hide Chrome’s generated header and footer

Chrome can add the page URL, title, date, and page numbers. Suppress those elements with:

chrome --headless --print-to-pdf --no-pdf-header-footer https://developer.chrome.com/

Wait for a page to finish loading

Use Chrome’s documented timeout flag when a page needs time for scripts or remote assets:

chrome --headless --timeout=5000 --print-to-pdf https://developer.chrome.com/

--timeout=5000 sets a maximum wait of 5,000 milliseconds before capture, even if loading is not complete. Increase it for heavier pages, but do not treat a successful process exit as proof that every image, font, or script finished loading.

When chrome is not on PATH

Call the installed executable by its full path. Chrome installation locations vary by machine and installation type. In PowerShell, quote a path containing spaces, then append the headless arguments. Verify the executable path in your Chrome shortcut or installation directory rather than assuming one universal location.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Convert a local HTML file

Pass a file URL so Chrome can resolve a local document:

chrome --headless --print-to-pdf "file:///C:/work/report.html"

Use forward slashes in the file URL. If the document references local images, stylesheets, fonts, or scripts, confirm that their paths are valid from the HTML file’s location. A relative URL that works on a web server can fail when opened from disk.

Rank #2
Dell Latitude 3190 11.6" HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
  • 1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core
  • 4GB DDR4 System Memory; 128GB Solid State Drive
  • 11.6" HD (1366 x 768) Multi-Touch Display
  • Combo headphone/microphone jack - Noble Wedge Lock slot - HDMI; 2 USB 3.1 Gen 1
  • Windows 11 Pro

For repeatable jobs, put the command in a batch file. Set the working directory first, call the Chrome executable, and check the generated PDF after each run. The Chrome reference establishes the print command and flags, but not one universal Windows argument for choosing an arbitrary output filename; confirm destination syntax against the Chrome build installed on your machine before relying on it in automation.

3. Check the PDF instead of trusting the exit code

Open the output and inspect:

  • Page breaks, widows, and tables split across pages.
  • Fonts, fallback glyphs, and text that is clipped or invisible.
  • Images, SVGs, background colors, and externally hosted assets.
  • Links, form controls, and generated content.
  • Headers, footers, margins, paper size, and landscape orientation.

A command can finish successfully while a site is still waiting on an API call, a font is blocked, or a page is protected by a bot check. For critical documents, compare a known-good sample PDF in your script and log the input URL, timestamp, exit code, and resulting file size.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Choosing a Windows command-line renderer

Chrome is usually the simplest choice when you need the same general rendering engine users see in a browser. Other tools are useful when you need a dedicated document pipeline or more print-oriented CSS control.

Tool Command or supported route Best fit Important caveat
Chrome Headless chrome --headless --print-to-pdf URL Direct browser printing and JavaScript-heavy pages Requires Chrome and a correct local executable path; output follows browser print behavior.
wkhtmltopdf wkhtmltopdf http://example.com example.pdf A small, dedicated URL/HTML-to-PDF command The project download page lists stable version 0.12.6, released June 11, 2020. Its rendering engine is older than current browsers.
Prince "C:Program Files (x86)Princeenginebinprince.exe" doc.html -o out.pdf CSS-oriented, print-focused document production Commercial software; check current licensing directly. It supports URL input when an output filename is supplied.
WeasyPrint weasyprint https://weasyprint.org output.pdf Windows CLI workflows with a Python-based option Unsupported CSS properties can generate warnings. Inspect the PDF for visual differences.

wkhtmltopdf: simple syntax, old release

Windows installers are available for wkhtmltopdf, and its basic pattern is:

wkhtmltopdf http://example.com example.pdf

The project lists 0.12.6 as its stable release from June 11, 2020. That age matters when a site depends on modern CSS, JavaScript, or browser security behavior.

The project also gives this security warning: “Do not use wkhtmltopdf with any untrusted HTML – be sure to sanitize any user-supplied HTML/JS, otherwise it can lead to complete takeover of the server on which it is running!” Treat HTML supplied by users as hostile. Sanitize it, isolate the process, restrict network access, and never run an unsafe conversion with administrative privileges.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 256 GB SSD of storage.
  • Multitasking is easy with 16GB of RAM
  • Equipped with a blazing fast Core i5 2.00 GHz processor.

Prince: print-oriented conversion

Prince installs a Windows executable under the installation’s Princeenginebin folder. Its documented example is:

"C:Program Files (x86)Princeenginebinprince.exe" doc.html -o out.pdf

Prince converts HTML and XML to PDF, supports CSS and JavaScript, and accepts a URL when an output filename is specified. It is a commercial option, so confirm the current license terms before deploying it.

WeasyPrint: Python and Windows routes

WeasyPrint documents a Windows release executable and an alternate Python installation. Its CLI form is:

weasyprint https://weasyprint.org output.pdf

Warnings about unsupported CSS are useful diagnostics, not proof that conversion failed. Review the rendered pages, especially if your design depends on browser-only properties, complex grids, animations, or JavaScript-generated content.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Make command-line conversion reliable

Prepare deterministic input

  • Use absolute or correctly rooted asset URLs.
  • Bundle fonts and images when network access is unreliable.
  • Add print-specific CSS with @media print.
  • Define page size, margins, and intentional page breaks in your stylesheet.
  • Freeze dynamic data when a reproducible PDF is required.

Separate renderer choice from validation

There is no documented benchmark here that makes one renderer universally fastest or most accurate. Test your own pages against the properties that matter: JavaScript execution, CSS pagination, fonts, SVG, accessibility, and licensing. Keep a small regression set and inspect PDFs after renderer upgrades.

Protect secrets and private pages

Do not place passwords or API tokens in URLs that may be logged. Use a controlled browser profile or request headers only when your chosen renderer supports them. For untrusted HTML, isolate the converter and sanitize scripts, external URLs, and embedded resources.

Rank #4
15.6 Inch Laptop Computer, N4020, 4GB DDR4 RAM, 128GB eMMC,with Windows 11
  • EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
  • 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
  • RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
  • ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
  • LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

6. Troubleshooting

“chrome is not recognized”

Chrome is not on PATH. Use the full executable path or add the Chrome directory to PATH, then open a new terminal and retry.

The PDF is blank or missing late content

The page may still be loading when capture occurs, or its content may require interaction. Increase --timeout, make sure the URL is reachable from that machine, and test a static version of the page. A bot check or authentication wall can also produce an apparently successful but unusable PDF.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Images or fonts are absent

Check relative paths in local files, HTTPS certificate errors, blocked mixed content, and network access from the conversion machine. Embed or locally host critical assets when repeatability matters.

Headers and footers appear unexpectedly

Add --no-pdf-header-footer. Page content created by your own CSS is separate from Chrome’s generated print decorations.

wkhtmltopdf output differs sharply from Chrome

This is expected when a page uses modern CSS or JavaScript. wkhtmltopdf’s listed stable release dates from 2020; try Chrome, Prince, or a simplified print stylesheet and compare the result.

WeasyPrint reports CSS warnings

Read the warning, identify the unsupported property, and provide a print-compatible fallback. Then inspect pagination, typography, and images in the resulting PDF.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage
  • WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
  • 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
  • 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
  • CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
  • LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.

Or skip the browser setup

ScreenshotNeo provides a website screenshot and PDF API at https://api.screenshotneo.com/v1/shot. It accepts cookie and consent banners before capture 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 the response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers. It also offers an MCP server with take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.

One-call cURL example

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for PDF parameters, output formats, and the complete option set.

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)

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 includes full-page capture with lazy images loaded, CSS-selector element capture, dark mode, device presets, custom viewports and retina scale, PDF paper size/margins/orientation/page ranges, custom CSS and JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, TTL caching, signed links, asynchronous jobs with signed webhooks, bulk capture for 100 URLs per call, usage data, and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.

Plans include 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to try it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can I convert HTML without installing a PDF library?

Yes. Chrome Headless can print a URL or local file directly, provided Chrome is installed and its executable can be invoked.

Why does a browser PDF not match the screen exactly?

PDF generation uses print rendering. Print CSS, pagination, margins, unavailable fonts, and content that loads after capture can all change the result.

Which renderer should process user-submitted HTML?

Use a sandboxed, least-privilege design and sanitize the HTML first. The wkhtmltopdf project specifically warns that unsanitized HTML and JavaScript can compromise the host.

Quick Recap

Bestseller No. 1
HP 14' HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
$249.99
Bestseller No. 2
Dell Latitude 3190 11.6' HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
Dell Latitude 3190 11.6" HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core; 4GB DDR4 System Memory; 128GB Solid State Drive
Bestseller No. 3
Dell Latitude 5420 14' FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
256 GB SSD of storage.; Multitasking is easy with 16GB of RAM; Equipped with a blazing fast Core i5 2.00 GHz processor.
$294.98

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.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.