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

Use your browser’s print dialog and choose Save as PDF. That is the simplest free method for an open webpage or a saved .html file. If you only have an unrendered HTML snippet, save it as an .html document, open it in Chrome or Firefox, and then print it. For repeatable jobs, an open-source command-line renderer such as wkhtmltopdf can convert a URL or file without opening a window.

The right steps depend on what you have: an open webpage, a local HTML file, or raw markup in an editor. This guide covers each case, print-layout settings, command-line conversion, common failures, and a browser-free API option.

Choose the method that matches your HTML

Starting point Free method Best for Important limitation
Webpage already open in a browser Chrome or Firefox print dialog One-off PDFs with a visual preview Print CSS and page settings can change the appearance
Saved .html file Open the file in a browser, then print to PDF Documents with local CSS, images, and fonts Relative files must remain in the expected folders
Raw HTML code in an editor Save as .html, render it, then print Markup that has not been displayed yet A browser prints the rendered page, not source code as text
Many URLs or scheduled conversions wkhtmltopdf or an API Scripts, build pipelines, and repeatable output Renderer compatibility and setup require testing

Browser help pages document printing an open page, image, or file in Chrome and Firefox. Chrome’s instructions are in Print from Chrome; Firefox documents its controls in How to print web pages in Firefox.

Convert an open webpage to PDF in Chrome

  1. Open the webpage in Chrome and wait until the content you need has loaded.
  2. Open File → Print, or press Ctrl+P on Windows/Linux or ⌘+P on macOS.
  3. In the destination or printer list, select Save as PDF (the wording can vary slightly by operating system).
  4. Set the paper size, orientation, page range, margins, scale, and whether backgrounds should print.
  5. Check the preview page by page, choose a filename and folder, then save.

Chrome prints the rendered document currently open in the tab. If a page has a cookie banner, chat panel, or sticky navigation bar, those elements may appear unless the site’s print stylesheet hides them or you hide them before printing.

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

Convert a webpage or file in Firefox

  1. Open the webpage or local HTML file in Firefox.
  2. Open the application menu and choose Print….
  3. Choose Save to PDF as the destination.
  4. Review the preview and set orientation, page range, color, paper size, scale, margins, headers and footers, and background printing.
  5. Save the PDF.

Mozilla warns that “Web pages can set themselves up to appear different on paper to how they look on screen, so don’t be surprised to see some changes.” Print-specific CSS, responsive breakpoints, and browser pagination can all alter the result.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.

Convert a saved HTML file

Keep the HTML file and its supporting assets together. A document such as report.html might refer to css/print.css, images/logo.png, or web fonts. Moving only the HTML file can produce missing styles or images.

  1. Double-click the .html file, or use the browser’s Open File command.
  2. Confirm that images, styles, tables, and links appear correctly in the rendered page.
  3. Use the Chrome or Firefox print steps above and select the PDF destination.
  4. Open the resulting PDF in a viewer and inspect every page, especially page breaks and images.

A local file that loads remote fonts, scripts, or images may behave differently without an internet connection. If an asset is essential, use a local copy with a correct relative path or test while connected.

Convert raw HTML code

A pasted snippet is not yet a document that a browser can print. Save it with an .html extension, then open that file. In a text editor, create a file named invoice.html containing a complete document such as:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Invoice</title>
  <style>
    body { font: 14px Arial, sans-serif; margin: 24px; }
    h1 { color: #174a7e; }
    @media print {
      .screen-only { display: none; }
    }
  </style>
</head>
<body>
  <h1>Invoice 1001</h1>
  <p>Prepared for Example Customer.</p>
  <p class="screen-only">This note is hidden when printed.</p>
</body>
</html>

On Windows, make sure the editor does not append .txt (for example, invoice.html.txt). On macOS or Linux, save the file as plain text with UTF-8 encoding. Open the saved file in a browser and print the rendered result. If you actually want the HTML source code printed as text, use your editor’s print or export command instead; browser print-to-PDF is designed for the rendered document.

Make the PDF fit the page

Use print preview before saving

  • Page size: Choose the paper used by your reader, such as A4 or Letter.
  • Orientation: Use landscape for wide tables and portrait for ordinary documents.
  • Margins: Reduce margins only when content is being clipped; excessive reduction can make text run to the edge.
  • Scale: Lower the scale when columns spill onto another page, but verify that text remains readable.
  • Page range: Select only the pages you need for a long report.
  • Background graphics: Enable background printing when colored panels, shaded table rows, or background images are part of the design.
  • Headers and footers: Turn browser-generated dates, titles, and URLs off when they are unwanted.

Control breaks with CSS

For a document you own, print CSS can prevent awkward splits:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.
@media print {
  .avoid-break { break-inside: avoid; }
  h1, h2 { break-after: avoid; }
  a { color: inherit; text-decoration: none; }
}

These rules influence pagination but do not guarantee identical results in every browser. Always check the preview rather than assuming the screen layout will be preserved.

Use wkhtmltopdf for repeatable conversion

wkhtmltopdf is described by its project as an open-source LGPLv3 command-line tool that renders HTML to PDF with Qt WebKit and runs headlessly. Its usage manual documents page size, orientation, margins, and background options.

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

After installing a build appropriate for your operating system, the basic form is:

wkhtmltopdf https://example.com report.pdf

For a local file, pass the file path (or a file URL supported by your installation):

wkhtmltopdf report.html report.pdf

Layout options can be added before the input and output names:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.
wkhtmltopdf --page-size A4 --orientation Portrait --margin-top 15mm --margin-bottom 15mm --background report.html report.pdf

This route is useful when the same conversion must run from a script or build job. It is not a promise of perfect fidelity for every modern, JavaScript-heavy site: Qt WebKit is a different rendering engine from current Chrome and Firefox. Test the actual pages you depend on, and use browser printing when visual parity with a current browser matters most.

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

Browser printing versus command line

Consideration Browser print-to-PDF wkhtmltopdf
Setup Usually none; use an installed browser Install and maintain a command-line tool
Best use Occasional, visual, interactive conversion Repeatable scripts and batch jobs
Preview Interactive preview before saving Inspect the generated file afterward
Controls Paper, scale, margins, backgrounds, and ranges in the dialog Documented command-line flags for paper, orientation, margins, and backgrounds
Rendering caveat May apply print CSS and browser-specific pagination Uses Qt WebKit, so modern site behavior may differ

Troubleshoot common conversion problems

The PDF is blank

Confirm that the source rendered in the browser before printing. For a local file, check that the file is not empty and that its markup is inside a complete HTML document. For script-generated content, wait until the content appears on screen, then print; a command-line renderer may need page-specific JavaScript handling that is not covered by the basic command.

Images or fonts are missing

Check relative paths, file permissions, and network access. Keep the asset folders beside the HTML file, use valid URLs, and reload the page before opening print preview. A disconnected computer cannot download remote assets.

Colors or shaded sections disappeared

Enable Background graphics or the equivalent background-print option. Some designs intentionally suppress backgrounds in print CSS, so inspect the stylesheet if the setting has no effect.

Content is cut off or columns overlap

Switch to landscape, choose a larger paper size, increase margins, or lower the scale. Wide tables often need a print-specific layout rather than simply smaller text.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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

The PDF has unexpected extra pages

Look for large fixed-height elements, oversized margins, and images that cannot shrink. Remove or override those rules in @media print, then verify each page in preview.

The screen and PDF look different

This is normal when the page defines print styles or when responsive CSS selects a different width. Use the print preview as the authority for the PDF, not the interactive screen.

wkhtmltopdf fails on a site that works in Chrome

The engines differ, and some sites require browser features that Qt WebKit does not provide. Try a simpler, static HTML source, adjust the document for that renderer, or use a current browser workflow for that page.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Optional advanced controls in Acrobat

Adobe documents additional web-to-PDF settings for input encoding, colors, backgrounds, image conversion, scrollable blocks, page size, orientation, margins, scaling, bookmarks, and PDF tags in Customize web page to PDF conversion settings in Acrobat. These controls are optional; browser printing and open-source command-line conversion cover the basic task without establishing a need for paid software.

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

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server that can return a clean screenshot or PDF from one GET request. Before capture it accepts consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup 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 headers.

Use the API documentation at https://screenshotneo.com/docs/ for request options. The same service supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, device presets or custom viewports, retina scale, PDF paper size, margins, landscape mode and page ranges, custom CSS and JavaScript, click actions, selector waits, network-idle waits, ad/tracker/request blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, configurable caching, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage information, and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.

cURL

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

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://example.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo’s MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients. Every feature is included on every plan: 1,000 shots per month are free with no card; paid plans start at $5 for 3,000 shots, with yearly billing providing two months free. If you need HTML-to-PDF conversion without maintaining a browser setup, create a free ScreenshotNeo account.

Frequently Asked Questions

Can I convert HTML to PDF without uploading the file?

Yes. Open a local file in your browser and use its built-in Save as PDF destination; the conversion happens on your computer.

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

Will links in the HTML remain clickable in the PDF?

Usually, browser-generated PDFs preserve links that are present in the rendered page. Open the saved PDF and test important links rather than assuming every custom script or overlay will be retained.

What should I do if I need the HTML source code, not its design?

Print the source from your editor or code viewer. Browser print-to-PDF renders the document, so it is the wrong workflow for producing a formatted listing of raw tags.

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.