October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Convert a URL to PDF with wkhtmltopdf and Preserve CSS

Use wkhtmltopdf to convert a URL to PDF, then troubleshoot missing CSS, assets, or JavaScript-rendered content with the right documented settings.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Convert a webpage with wkhtmltopdf https://example.com/page output.pdf. To preserve its styling, make sure the page’s CSS and other assets can load, then choose screen or print media and allow enough time for JavaScript-driven content to appear. wkhtmltopdf offers controls for these cases, but they do not guarantee that every site will render exactly as it does in a modern browser.

Convert a URL to PDF

wkhtmltopdf accepts a URL or filename as page input and converts HTML pages to PDF using its “wkhtmltopdf patched qt” renderer. For a single remote page, run:

As an Amazon Associate I earn from qualifying purchases.

wkhtmltopdf https://example.com/page output.pdf

Replace the example URL with the page you want and output.pdf with the destination filename. The wkhtmltopdf usage manual documents the command and its options.

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

Make CSS and assets available to the renderer

A page can only be styled with CSS and images that the renderer can load. If styles or assets are missing, check their URLs and access requirements first. The manual also offers --user-style-sheet <path> to apply an additional stylesheet; it does not replace a site’s own CSS or ensure modern browser-level fidelity.

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

For local HTML and assets

When converting a local HTML file that references other local files, access controls may prevent those assets from loading. The manual documents --disable-local-file-access, which blocks access to other local files unless permitted, and --allow <path>, which permits a specified path. If local assets are needed, allow only the directory that contains them rather than opening broad access without considering what the input could read.

Check images and backgrounds

The --images and --background options are enabled by default. If images or background styling are absent, check whether the referenced files are reachable and whether those options have been disabled in your command or configuration.

Choose media, viewport, and rendering time

Which settings help depends on how the page is built. The documented defaults and controls are starting points, not a universal recipe; change one setting at a time and inspect the resulting PDF.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
What to check Documented behavior and possible adjustment
Screen or print styling Screen media is the default. Use --print-media-type to select print media when that matches the intended output.
JavaScript-rendered content JavaScript is enabled by default, with a default delay of 200 ms. For content that appears asynchronously, try a longer --javascript-delay or wait for a page status with --window-status.
Viewport and overflow --viewport-size can set a viewport size for pages with custom scrollbars or CSS overflow behavior. Smart shrinking is enabled by default.
Resource and page load errors Media load errors are ignored by default, while page-load errors abort by default. Choose error handling deliberately when diagnosing a missing resource or failed load.

The settings are documented in the usage manual and the library settings reference. Neither source promises exact rendering parity with current browsers.

Check your installed build

Run wkhtmltopdf -H to see the help output for the binary installed on your system. The project says its documentation is autogenerated from this help output, and builds can differ; use the local output when an option behaves differently than expected. See the project documentation page.

Troubleshoot missing styling or content

  • CSS is absent: confirm stylesheet URLs are reachable from the machine running wkhtmltopdf. For local HTML, check access controls and use a narrowly scoped --allow <path> if local stylesheets or assets must be read.
  • Images or backgrounds are missing: confirm the referenced resources load, and check that --images or --background has not been turned off.
  • Content appears incomplete: if it depends on JavaScript, try increasing --javascript-delay or waiting for a relevant --window-status.
  • Layout differs from the webpage: check whether the page is designed for screen or print media. If overflow or custom scrollbars are involved, test a suitable --viewport-size.
  • A load failure stops conversion: distinguish a page-load error from a media-resource error; the defaults treat them differently. Consult the installed binary’s help output before changing error handling.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a screenshot rather than a PDF, ScreenshotNeo is a website screenshot API and MCP server. One GET request can return an image or PDF; for example, this cURL call saves a WebP screenshot:

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
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 API documentation for request options. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free.

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.

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.

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
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.