For a one-off webpage, use headless Chrome or Chromium: chromium --headless --print-to-pdf=page.pdf --no-pdf-header-footer 'https://example.com/'. For repeatable conversions in an application, use Puppeteer or Playwright; for authored HTML/CSS documents that do not depend on browser JavaScript, consider WeasyPrint. Prince is a commercial option for specialized publishing. The right choice depends on whether the page needs JavaScript, how closely it must match browser rendering, and how much control you need over print layout.
Choose a Linux HTML-to-PDF tool by the page you need to render
| Need | Good starting point | Important qualification |
|---|---|---|
| Save one live webpage from a shell | Headless Chrome or Chromium | Check timing and whether the page’s JavaScript-populated content has appeared. |
| Render URLs as part of Node.js automation | Puppeteer or Playwright | Handle authentication, app readiness, lazy content and assets explicitly where needed. |
| Generate a controlled report or document from HTML/CSS | WeasyPrint | It is a print-focused HTML/CSS renderer, not a full browser JavaScript engine. |
| Specialized paged publishing | Prince | Commercial software; evaluate licensing and output against your documents. |
| Maintain an existing wkhtmltopdf workflow | Assess the existing deployment | The project describes a Qt WebKit-based command-line renderer; current lifecycle and suitability are not established here. |
For any engine, confirm it can resolve the document’s fonts, images, stylesheets and other assets. Validate page breaks, print colors, headers and footers, links, and JavaScript-generated content in a representative PDF before relying on it.
As an Amazon Associate I earn from qualifying purchases.
How to save a webpage as a PDF from the Linux command line
Use headless Chrome or Chromium for a one-off URL
Chrome for Developers documents --print-to-pdf as saving the target to output.pdf in the current directory by default. Set a filename by adding it after an equals sign:
chromium --headless --print-to-pdf=page.pdf --no-pdf-header-footer 'https://example.com/'
Omit --no-pdf-header-footer if you want the browser’s URL, date or page-number furniture. The executable may be named chrome, chromium or chromium-browser, depending on the Linux package and distribution. Use the name provided by your installation rather than assuming one alias.
#1 Best Overall
- Intel Core i5-1335U Processor (12M Cache, 12 Threads, up to 4.6 GHz) - 256GB Solid State Drive - 16GB DDR4 SDRAM
- 15.6" FHD (1920x1080) Non-Touch Anti-Glare Display - Intel UHD 620 Integrated Graphics - Stereo Speakers
- 720p HD Webcam with Privacy Shutter. Integrated Microphone - Intel Dual Band Wireless-AC (2x2) 8265, Bluetooth Version 4.2
- I/O Ports: 2x USB 3.0, 1x USB 3.1 Type-C 3.1, Headphone/Mic Combo Port, 4-in-1 Card Reader, HDMI, Kensington Mini-Lock Slot
- Linux Mint (Cinnamon) 64-Bit - Keyboard with Full NumberPad - Fast Charging
Allow time-dependent pages to render
Chrome’s headless CLI offers timing controls such as --timeout=5000 and --virtual-time-budget=42000. The first allows capture after up to five seconds; the second can fast-forward time-dependent code. They control capture timing but do not prove that all network requests finished or that an application reached the state you want. A page that loads data after a user action may need a browser-automation script instead.
Convert local HTML
Use a local file path when the source is a file, and a URL for a live page. Before converting local HTML, check that relative image, font and stylesheet paths resolve from the document’s location. For a live page, confirm network access and any required authentication. These Chrome flags and behaviors are documented in the Chrome headless command-line reference.
Automate conversion with Puppeteer or Playwright
Puppeteer: a Node.js PDF workflow
Puppeteer is useful when PDF creation is one step in a Node.js browser-automation process. Its API prints using print CSS by default and waits for fonts by default. This example follows the documented pattern; choose a readiness condition that fits the page rather than assuming one wait strategy works everywhere.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteRank #2
- Intel Core i5-10210U (up to 4.2GHz) - 1TB PCIe NVMe + 1TB HDD - 32GB DDR4 SDRAM
- 17.3" HD+ (1600x900) Display, Intel UHD Graphics 620
- Built in HD 720p Webcam with Microphone - Bluetooth Version4.2
- I/O Ports: 2x USB 3.1 (Data Only), 1x USB 2.0, 1x HDMI, 1x Headphone/Microphone Combo Jack
- Linux Mint Cinnamon 64-Bit - 6-Row Keyboard w/ Full Numberpad
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com/', { waitUntil: 'networkidle2' });
await page.pdf({ path: 'page.pdf' });
} finally {
await browser.close();
}
})();
If the page should use screen styles rather than print styles, call await page.emulateMediaType('screen') before page.pdf(). The networkidle2 navigation condition is only a starting point: authentication, blocked assets, lazy-loaded sections or application-specific readiness may require additional code. See Puppeteer’s PDF generation guide and Page.pdf() API.
Playwright: reuse a browser automation stack
Choose Playwright when it already fits your application’s browser automation needs. On Linux, account for its browser installation model: Playwright documents regular Chromium builds and a separate headless shell, and supports installing only the headless shell when that is sufficient for a CI job. Match the installed browser to the Playwright package and deployment environment. Its current browser guidance is at Playwright browsers.
Use WeasyPrint for authored HTML and CSS documents
WeasyPrint provides a command-line interface and a Python API for HTML/CSS-to-PDF rendering. Its CLI accepts a local filename or URL:
Rank #3
- [ULTRA-RUGGED DESIGN] MIL-STD-810G and IP65 certified. Built to survive 6-foot drops, heavy rain, and extreme vibrations. Features a magnesium alloy chassis with an integrated carry handle for maximum portability
- [4G LTE - WORK ANYWHERE] Integrated 4G LTE Multi-Carrier Mobile Broadband. Stay connected to the internet in remote areas or on the road without relying on Wi-Fi or phone hotspots. True mobile freedom for field professionals
- [1200-NIT SUNLIGHT READABLE] 13.1" XGA Touchscreen with CircuLumin technology. At 1200 nits, it is nearly 4x brighter than a standard laptop, ensuring perfect visibility under direct, intense sunlight
- [LINUX UBUNTU PRE-INSTALLED] Fast, secure, and bloatware-free. Optimized for developers, network engineers, and diagnostic software that thrives in a stable, open-source environment
- [LEGACY SERIAL PORT] Features a native RS-232 Serial Port, HDMI, and USB 3.0. Essential for connecting directly to industrial machinery, CNCs, and automotive diagnostic tools without unreliable adapter
weasyprint report.html report.pdf
WeasyPrint is designed for print rendering; do not choose it on the assumption that it will run page JavaScript like a full browser. Its documentation says unsupported CSS properties may produce warnings, so inspect output and logs for documents that rely on particular styling.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Install for the Linux environment you actually run
Package names and dependency handling vary. WeasyPrint’s documentation says recent Debian, Ubuntu, Fedora, Arch Linux and Gentoo releases package it. The surfaced stable documentation is version 70.0, which lists Python 3.10 or later and Pango 1.44 or later among its requirements; package-manager installations may handle dependencies for supported distributions. Check the requirements for your target Linux release before choosing a package or pip installation. If installing through pip, use a virtual environment and verify system dependencies first. See WeasyPrint 70.0 First Steps.
Set page size and margins with CSS
WeasyPrint uses CSS @page for page geometry rather than command-line page-size switches. Put the rule in the document’s stylesheet or pass a stylesheet with -s:
Rank #4
- THE POWER TO STAY PRODUCTIVE – Looking to make your everyday work and home life more manageable without breaking the bank? The Lenovo V15 Gen 4 offers long-term reliability with top-of-the-line features to make you your most productive self.
- CRUSH YOUR TO-DO LIST – The AMD Ryzen CPU pairs quiet performance and enhanced operating power to crush your high-demand workday. It optimizes performance and allows for seamless multitasking.
- TRUE-TO-LIFE VISUALS – The 15.6” FHD IPS display is anti-glare with 300 nits brightness to see your best outside or in. Its 88% screen-to-body ratio makes viewing detailed applications like spreadsheets a breeze.
- SEAMLESS COLLABORATION – Lenovo Smart Appearance enhances your camera effects to protect your privacy and to make you the focus of every video conference. Intelligent noise cancelation minimizes distraction and Dolby Audio provides an elegantly sonorous experience.
- BUILT TO WITHSTAND – Built for military-grade toughness, the V15 Gen 4 is tested to withstand harsh temperatures, pressure, humidity, vibrations and more. Keep your work safe from the board room to your living room and everywhere in between.
/* print.css */
@page {
size: A4 portrait;
margin: 15mm;
}
weasyprint -s print.css report.html report.pdf
Choose the paper size, orientation and margins that match the document’s intended output, then check actual page breaks and content clipping. See the WeasyPrint documentation for CLI and API details.
When Prince or wkhtmltopdf makes sense
Prince for specialized publishing
Prince documents HTML/XML conversion with CSS and JavaScript support, a command-line workflow and advanced paged-output capabilities. It is commercial software. Check current Linux licensing and evaluate it with representative documents before adopting it; the available product documentation does not establish a current price. Its user guide and version 12 command-line reference describe capabilities, but the latter is version-specific.
wkhtmltopdf for an existing deployment
The official project site describes wkhtmltopdf as an open-source command-line renderer based on Qt WebKit. That description alone does not establish whether it is maintained today or appropriate for a current web application. Before using it for a new system, check current releases, your distribution’s package status and security maintenance, then test its output against the actual pages you need to convert. The project description is at wkhtmltopdf.org.
Best Value
- Powerful Linux Laptop: This IdeaPad Slim 3 Laptop comes pre-installed with Ubuntu Linux, offering fast performance, robust security, and a clean, user-friendly experience. Enjoy full customization, seamless hardware compatibility, and access to thousands of open-source apps. Whether you're working, creating, or coding, it's built to keep up with everything you do.
- A Multitasking Master: The latest AMD Ryzen 7 5825U processor (up to 4.5 GHz) delivers powerful performance with 8 cores and 16 threads for smooth multitasking. Integrated AMD Radeon Graphics provide crisp visuals for streaming, browsing, photo editing, and casual gaming. With smart machine intelligence, it adapts to your needs for a fast, responsive experience.
- 15.6" Full HD Display: The IdeaPad Slim 3 boasts an 88% screen-to-body ratio for a floating, edge-to-edge visual experience. TÜV Low Blue Light certification reduces eye strain, making it perfect for long work or study sessions.
- Military-Grade Durability: The smart IdeaPad Slim 3 combines portability and durability, letting you work, study, and play on the go. With a profile 10% slimmer than the previous generation, it's lightweight yet military-grade rugged, ready for anything, anywhere.
- Versatile Connectivity: Enjoy the security of a built-in webcam with a privacy shutter. Connect effortlessly with multiple ports: 2x USB A, 1x USB C, 1x HDMI, 1x SD Card Reader, 1x Headphone/Microphone combo. Bundle comes with Stylus Pen, 256GB Portable SSD and 5-in-1 Docking Station.
Protect the system when rendering untrusted HTML
HTML-to-PDF conversion can cross a security boundary. WeasyPrint documents risks including local-file access, excessive resource use, long renderings and network fetching when markup or styles are untrusted. Treat user-controlled HTML and CSS as potentially hostile, regardless of the engine chosen.
- Run the renderer with restricted filesystem and network access.
- Restrict or filter resource fetching so user content cannot freely read local files or access network resources.
- Set execution-time and memory limits to contain long or resource-intensive renders.
- Consult the selected engine’s current security guidance before exposing a conversion service.
See WeasyPrint’s security guidance for its documented risks and precautions.
Troubleshoot missing or incorrect PDF content
| Symptom | Likely cause | What to check |
|---|---|---|
| Images, fonts or styles are missing | The renderer cannot resolve a relative path, fetch a remote asset, or access a protected resource. | Check the HTML’s base location, asset URLs, filesystem permissions, network access and authentication. |
| Content populated by JavaScript is absent | The selected renderer does not execute the page’s JavaScript, or capture occurs before the page is ready. | Use a browser engine for JavaScript-dependent pages; add an application-specific readiness condition where needed. |
| Print layout differs from the browser window | The PDF uses print media styles, or the document’s print CSS changes visibility and layout. | Review print styles; with Puppeteer, use page.emulateMediaType('screen') before printing if screen media is intended. |
| WeasyPrint emits CSS warnings or output misses a style | The property may not be supported by the renderer. | Check the warning and WeasyPrint’s CSS support for the installed version; adjust the stylesheet or use a browser engine if the page depends on that behavior. |
| PDF has unwanted URL, date or page-number text | Chrome’s header and footer display is enabled. | Add --no-pdf-header-footer to the headless Chrome command. |
| Page is blank or incomplete despite a delay | A timeout or virtual-time budget does not guarantee application readiness, successful network activity or completed user-triggered work. | Check browser access, authentication, failed assets and the page’s actual readiness state; use automation when the capture needs explicit interaction. |
Or skip the browser setup
If the task is to capture a website as an image or PDF rather than build a local HTML-to-PDF pipeline, ScreenshotNeo is a website screenshot API and MCP server. Its API returns PNG, JPEG or WebP screenshots or a PDF. A simple URL capture uses one GET request:
Crashes, 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 minuteWindows 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 reinstallcurl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/ -o shot.webp
See the ScreenshotNeo API documentation for request options. Cookie and consent banners, newsletter popups and chat widgets are removed before capture; bot checks, blank pages and failed loads are not billed. Its MCP server lets AI agents take screenshots, and the Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots. Sign up for free: 1,000 screenshots a month, no card required.
Frequently asked questions
Can I convert a webpage to PDF without writing a script?
Yes. A headless Chrome or Chromium command can print a URL directly to a PDF from the shell.
Does WeasyPrint execute JavaScript?
Do not treat it as a full browser JavaScript engine. Use a browser-based renderer when the page’s content depends on JavaScript execution.
Is wkhtmltopdf maintained?
The project description identifies its Qt WebKit basis and command-line purpose, but does not establish its current maintenance status. Check current releases and security support before adopting it.
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.




