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

To save an HTML webpage as a PDF, open it in a browser, choose Print, select Save as PDF (or the equivalent PDF destination), check the preview, and save. For repeatable conversions, Chrome Headless and wkhtmltopdf can create PDFs from the command line. The right route depends on whether you have a local HTML file or a live page, and whether you need a one-off copy or an automated workflow.

Choose the conversion method that fits your page

Method Best for Main consideration
Browser Print → Save as PDF A one-time conversion, including a local HTML file you can open in a browser Review the preview and adjust page layout before saving.
Chrome Headless Repeatable or scripted conversions using Chrome Choose when the page needs a current browser renderer or configurable capture timing.
wkhtmltopdf A command-line workflow using its Qt WebKit renderer It is a different rendering engine from Chrome; check the output for pages that depend on modern browser features.

None of these methods can guarantee that every page will print exactly as it appears on screen. The result depends on the page’s print styling, linked resources, dynamic content, and chosen page settings. There are no comparative performance or compatibility test results here, so check a representative output before adopting a method for a larger job.

Save a webpage as PDF in a browser

  1. Open the page. Navigate to the webpage, or open the local .html file in your browser.
  2. Open Print. Common shortcuts are Ctrl+P on Windows or Linux and Command+P on macOS. Shortcuts and menu labels can vary by browser and operating system.
  3. Choose a PDF destination. In the print dialog’s destination or printer choice, select Save as PDF or your platform’s equivalent PDF output. You do not need a physical printer.
  4. Check the preview. Inspect page breaks, orientation, scale, margins, images, and any essential text before saving. If content is clipped or split awkwardly, adjust the available layout settings and inspect the preview again.
  5. Save the file. Select a location and filename, then open the saved PDF to confirm it contains the pages and content you need.

Browser menus differ, and the Chrome Headless reference is a command-line guide rather than a step-by-step manual for every desktop browser. If a menu is named differently on your system, look for the browser’s Print command and the PDF destination in its print dialog.

Convert an HTML file or webpage with Chrome Headless

Chrome’s documented Headless option is --print-to-pdf. Run the command in a terminal with the page URL:

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.
chrome --headless --print-to-pdf https://example.com/

By default, Chrome writes output.pdf in the current working directory. Specify another filename with an equals sign:

chrome --headless --print-to-pdf=page.pdf https://example.com/

For a local document, provide a file:// URL with an absolute path:

chrome --headless --print-to-pdf=page.pdf file:///absolute/path/to/page.html

Replace the example URL or path and output filename with your own. The Chrome reference provides these options and discusses additional timing and header/footer flags at Chrome Headless command-line reference (last updated 2024-10-21 UTC).

Control headers, footers, and capture timing

  • Remove Chrome’s generated print header and footer: use --no-pdf-header-footer. Chrome notes that the older flag name, --print-to-pdf-no-header, may be needed with an older version. Check the documentation for the Chrome version you run.
  • Set a maximum wait: --timeout accepts a wait in milliseconds before capture, even if the page is still loading. A timeout is a limit, not proof that a site’s asynchronous work has finished.
  • Allow time-dependent code to advance: --virtual-time-budget can let page code advance under virtual time before capture. It may help with content populated after the initial load, but cannot ensure that every site-specific task has completed.

Chrome documents these controls, as well as JavaScript execution before DOM serialization, in its Headless command-line reference. Use the timing option that fits the page, then inspect the resulting PDF rather than assuming that a longer wait has captured every interactive or delayed element.

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

Use wkhtmltopdf as another command-line option

wkhtmltopdf is an open-source, LGPLv3 headless command-line tool that renders HTML to PDF using the Qt WebKit engine. Its project page gives this basic pattern:

wkhtmltopdf http://google.com google.pdf

Replace the example address and output filename with the page and PDF you want. The tool’s usage documentation describes options for JavaScript and JavaScript delay, image loading, print media, load errors, local-file access, headers and footers, paper size, and page layout.

For example, --print-media-type selects print media instead of screen media. JavaScript is enabled by default in the documented manual, and --javascript-delay provides a configurable wait. Local-file access is controlled by explicit command-line options. The exact set of available flags can depend on the installed version, so check that version’s manual before relying on a particular option.

Because wkhtmltopdf uses Qt WebKit rather than Chrome’s renderer, its output should not be assumed to match a current browser on pages that rely on modern browser features or complex scripts. Compare the PDF with the page in a current browser and keep a representative example when deciding whether the renderer meets your needs.

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

Make the PDF readable and complete

Check layout before distributing or archiving

A screen layout may not paginate naturally. A wide page can become cramped in portrait orientation; a long element can split at an awkward point; margins and scale can make text too small. Use print preview when converting interactively, or inspect the generated PDF when converting from the command line. Check the first, middle, and final pages of a long document, not just the opening page.

Check every dependency of a local HTML file

An HTML file is not necessarily self-contained. Its stylesheets, fonts, images, and scripts might be separate local files or remote resources. If they are missing, inaccessible, or unreachable when conversion runs, the PDF can lose styling, images, or content. A file that opens on one computer may behave differently on another if the linked resources or their paths are not available there.

Account for generated and interactive content

Some pages populate content after initial navigation, depend on scripts, or require login or user interaction. A PDF capture takes a snapshot at a particular point in loading and rendering; it does not automatically complete every interaction a person could perform. For automated conversion, test the page with the chosen timing controls and inspect whether the needed content appears.

Troubleshoot common conversion problems

  • The PDF is blank or incomplete: Confirm that the local file opens normally or that the webpage is reachable. Check whether the page is behind a login, waiting for an interaction, or still populating content. With Chrome, try an appropriate --timeout or --virtual-time-budget, then inspect the saved PDF.
  • Images or styles are missing: Identify whether the assets are embedded, linked locally, or loaded from remote addresses. Ensure the converter can reach them. For wkhtmltopdf, consider its documented image-loading and local-file-access controls; enable local access only when appropriate for the files being converted.
  • Page breaks or text size are wrong: In a browser, adjust scale, orientation, and margins in print preview. With a command-line renderer, use its documented page-layout settings and inspect a new output rather than assuming screen styling will paginate well.
  • Chrome adds a date, URL, or page number: For Headless PDF creation, try the documented --no-pdf-header-footer flag. If it is not recognized, check whether your installed Chrome version needs the older --print-to-pdf-no-header name.
  • A command-line PDF is missing or stale: Check the command’s exit status, confirm the output filename and working directory, and open the actual generated file. On pages with delayed content, tune capture timing and test again. For batch work, validate representative pages instead of treating a successful command as proof that every PDF is complete.
  • A local file cannot load its dependencies: Check that the referenced paths are valid from the conversion environment and that the tool is allowed to access the required local files. wkhtmltopdf’s manual documents local-file access controls; consult the installed version’s manual for its exact behavior.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Automate repeated conversions carefully

For one document, browser printing is usually the simplest route because you can see the preview and correct the layout before saving. For repeated conversions, a command-line renderer is easier to invoke consistently, but reliability still depends on the input page and its resources. Keep the renderer version and relevant options consistent across runs, check command results and output files, and review a representative PDF after changes to the HTML or conversion setup.

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

For a collection of local pages, verify that each input path and its dependencies are available to the process doing the conversion. For live URLs, account for network access, authentication, and pages whose content is produced after navigation. Chrome’s documentation also describes multiple invocations from standard input for batch use with wkhtmltopdf; consult its usage documentation for the syntax supported by the version you install. No single wait setting can certify that arbitrary dynamic pages have finished rendering.

Or skip the browser setup

For a live webpage, ScreenshotNeo can return a PDF as well as PNG, JPEG, or WebP. Its GET endpoint is https://api.screenshotneo.com/v1/shot; the following supplied cURL call requests a shot of an example URL and saves the response as an image. See the ScreenshotNeo documentation for PDF output settings and the API options.

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 or consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Details are at ScreenshotNeo.

Sign up for ScreenshotNeo free: 1,000 screenshots a month, no card required.

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

Frequently Asked Questions

Does converting HTML to PDF require a physical printer?

No. Choose a PDF destination such as Save as PDF in the browser’s print dialog; it creates a file rather than printing on paper.

Can I use Chrome Headless with a local HTML file?

Yes. Use a file:// URL containing the file’s absolute path, and check that any linked local or remote resources can load in the conversion environment.

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.