October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
CairoSVG

How to Add SVG Support to wkhtmltopdf PDFs (and Fix Blank or Rasterized Artwork)

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.

There is no general wkhtmltopdf switch that enables every kind of SVG. The documented SVG options target checkbox and radiobutton controls. For other artwork, reliable output depends on your wkhtmltopdf version and Qt build, how the SVG is embedded, and which SVG features it uses. Start with a minimal reproduction, test the inclusion method and inspect the generated PDF at high zoom. If the result is still blank, incomplete or rasterized, convert the SVG with librsvg or CairoSVG before inserting it into your document workflow.

What wkhtmltopdf actually supports

wkhtmltopdf converts HTML to PDF using a Qt-based rendering engine. Its usage documentation lists four SVG-related options:

  • --checkbox-checked-svg
  • --checkbox-svg
  • --radiobutton-checked-svg
  • --radiobutton-svg

Those options supply artwork for checked and unchecked form controls. They are not a general-purpose “turn on SVG support” setting for logos, diagrams, charts or arbitrary inline graphics. Treat ordinary SVG rendering as a compatibility question that must be tested with your exact binary.

Diagnose the renderer before changing your HTML

Record the version and Qt build

Run:

wkhtmltopdf --version

Save the complete output, including whether it says the binary uses patched Qt. Issue reports show different behavior between distribution builds without patched Qt and patched-Qt builds; the version number alone does not identify the rendering path.

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

Make a one-file reproduction

Create a small HTML file that contains one SVG and no framework, JavaScript bundle or external stylesheet. Use the same command you use in production:

wkhtmltopdf test.html test.pdf

A minimal inline test helps distinguish SVG compatibility from URL, asset, CSS or timing problems. If your SVG is a local file and your build blocks local resources, use the local-file-access option supported by that build or serve the test directory over HTTP. Keep the exact command in your test notes so a later build comparison is meaningful.

Inspect the PDF, not only the HTML preview

Open the PDF at high zoom. A graphic that looks correct in a browser can be absent, clipped, opaque, or converted to a bitmap in the PDF. If scalable vector output is a requirement, zoom far beyond normal reading size or inspect the PDF with a tool that can identify image and path objects. A reported wkhtmltopdf 0.12.5 patched-Qt case produced rasterized SVG artwork, so the .svg extension in your source is not proof that the PDF contains vectors.

Test each SVG inclusion method

Do not assume that <img>, inline SVG and <object> take the same rendering path. Build a test page with one copy of the same artwork in each form:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<!-- External SVG as an image -->
<img src="logo.svg" width="320" height="120" alt="Company logo">

<!-- Inline SVG -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 120"
     width="320" height="120" role="img" aria-label="Company logo">
  <rect width="320" height="120" fill="#123456"/>
  <path d="M30 90 L90 30 L150 90 Z" fill="#fff"/>
</svg>

<!-- Object embedding -->
<object data="logo.svg" type="image/svg+xml" width="320" height="120">
  <img src="logo-fallback.png" width="320" height="120" alt="Company logo">
</object>

A 2017 issue report describes an <object>-included SVG rendering blank while another inclusion path behaved differently. That is a failure mode to investigate, not a universal rule that one tag always works. Test the method that matches your production markup and retain a PNG fallback when a missing logo is unacceptable.

SVG features that commonly expose build differences

Embedded raster images

SVG files that contain JPEG or PNG data can fail differently from paths and simple fills. A report involving wkhtmltopdf 0.12.3 with patched Qt found that an embedded JPEG did not appear when the SVG was loaded as an image; putting the SVG markup directly in HTML produced a different, still imperfect result. Temporarily remove the embedded image and render the paths alone. If the paths work, either externalize the raster image or pre-render the complete asset.

Clipping paths and opacity

Another report compared a distribution build and a patched-Qt build and identified problems involving clip-path and opacity. Reduce the file to one clipping path or one translucent element, then add effects back one at a time. This isolates a feature limitation from an unrelated layout error.

External resources, fonts and CSS

Keep fonts, images and stylesheets available to the converter at capture time. A browser may resolve a relative URL, wait for a web font and execute application code before painting; a headless conversion can reach a different state. For a deterministic test, inline critical CSS and use local or fully qualified asset URLs that your build can access.

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.
Rank #3
Sale
CNC Programming Handbook, Third Edition
  • New
  • Mint Condition
  • Dispatch same day for order received before 12 noon
  • Guaranteed packaging
  • No quibbles returns

A repeatable troubleshooting procedure

  1. Capture the environment. Record wkhtmltopdf --version, operating system, package source and patched-Qt status.
  2. Reduce the input. Use one HTML file, one SVG and a plain background. Remove frameworks, animations and unrelated JavaScript.
  3. Compare inclusion modes. Test inline SVG, <img> and <object> separately. Save each PDF with a distinct name.
  4. Bisect SVG features. Remove embedded images, clipping paths, opacity, masks, filters and external fonts; restore them individually.
  5. Check resource access. Confirm every image, stylesheet and font URL is reachable from the conversion process. Verify local-file permissions for your build.
  6. Check timing. If the SVG is inserted by JavaScript, make a static test file or wait for a selector/delay in the surrounding workflow before converting.
  7. Verify the PDF representation. Inspect at high zoom and determine whether the artwork is missing, clipped, blurred or rasterized.
  8. Choose a fallback deliberately. Simplify the SVG, convert it separately to PDF or PNG, or isolate that page in another renderer instead of repeatedly changing unrelated HTML.

Use a dedicated SVG converter when fidelity matters

When wkhtmltopdf cannot render the artwork acceptably, convert the asset before the HTML-to-PDF step. This separates SVG parsing from page layout and gives you a known intermediate file.

librsvg and rsvg-convert

GNOME’s librsvg documentation describes rsvg-convert output to PDF and includes page-sizing controls. A typical conversion is:

rsvg-convert -f pdf -o logo.pdf logo.svg

Use the documented width and height options when the SVG’s intrinsic size does not match the page slot. Then place the resulting PDF in a workflow that supports PDF fragments, or convert it to a PNG at the final display resolution when your HTML engine only accepts raster images. Verify transparency, page dimensions and any filters used by the original file.

CairoSVG

CairoSVG describes itself as an SVG 1.1 to PNG, PDF, PS and SVG converter. Its Python API can produce either PDF or PNG:

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

cairosvg.svg2pdf(url="logo.svg", write_to="logo.pdf")
cairosvg.svg2png(url="logo.svg", write_to="logo.png", output_width=1200)

Check CairoSVG’s supported-feature documentation against your artwork. Conversion is not a guarantee that every SVG filter, mask, font or embedded resource will match a browser. Render a proof PDF and compare it with the source before deploying the result.

Choosing PDF versus PNG

Approach Vector output Embedded images Pipeline fit Main qualification
wkhtmltopdf with original SVG Not guaranteed; inspect the PDF Can fail in particular builds and inclusion modes Lowest change to an existing HTML job Behavior depends on version, Qt build and SVG features
librsvg rsvg-convert to PDF Designed for PDF conversion Test the source artwork Requires a separate conversion step and a way to place PDF output Use documented page-sizing controls for your layout
CairoSVG to PDF PDF conversion available Test against its supported features Python or CLI integration Documentation notes feature limitations
Dedicated converter to PNG No; raster by design Usually simpler to place in HTML Works with image-only pipelines Choose output dimensions and inspect for blur

Use PDF output when the downstream document pipeline can place it and scalable artwork is important. Use PNG when predictable placement in HTML is more valuable than infinite zoom, and generate it at a sufficient output size.

Common symptoms, causes and fixes

Symptom Likely cause to test Practical fix
Entire SVG is blank <object> handling, inaccessible URL or unsupported external resource Try inline SVG and <img>; verify resource access; keep a PNG fallback
Paths appear but an embedded photo is missing Embedded raster-image handling in the installed build Externalize the image, simplify the SVG, or pre-convert it
Artwork is clipped clip-path, viewBox or page-size interaction Test without clipping, set an explicit viewBox and dimensions, then compare a converted PDF
Transparency looks opaque Opacity/compositing difference between Qt builds Test a flat-color version or pre-render with librsvg/CairoSVG
PDF looks sharp at normal size but blurry when enlarged SVG was rasterized Inspect the PDF representation and use a vector-capable conversion path
Works on one machine only Different package, Qt patch, fonts or resource permissions Pin and record the renderer build; run the minimal fixture in every deployment environment
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Maintenance implications

The upstream wkhtmltopdf repository was archived on January 2, 2023. That status does not establish whether a distributor or fork is maintained, but it does mean a workaround should be evaluated as a maintenance decision, not only a one-line command change. Keep a fixture containing the SVG features your product uses, compare PDFs after package updates, and document the exact converter used for production.

Or skip the browser setup

If your immediate need is a clean visual capture of the rendered page rather than a locally managed wkhtmltopdf pipeline, ScreenshotNeo provides a website screenshot API and MCP server. 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 turned off. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. It is not a promise of SVG vector preservation in a PDF, so keep the converter workflow above when PDF internals matter.

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

One GET request is enough for a screenshot (see the ScreenshotNeo API documentation):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
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)
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 also offers an MCP server for Claude, Cursor and other MCP clients, with take_screenshot, get_page_info and capture_pdf tools. Every feature is on every plan: 1,000 shots per month are free with no card; paid plans start at $5 for 3,000 shots. Sign up for the free ScreenshotNeo plan.

FAQ

Do the checkbox SVG flags enable logos and charts?

No. They are documented for checkbox and radiobutton control artwork, not as a universal SVG compatibility switch.

How can I prove that a PDF still contains vectors?

Inspect the generated PDF at high zoom and with a PDF inspection tool; browser sharpness alone cannot establish the internal representation.

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

Should I replace wkhtmltopdf immediately?

Not necessarily. First reproduce the failure with your exact build and SVG. Replace or isolate the step when required features remain unreliable, considering the archived upstream repository.

Frequently Asked Questions

Can I fix every SVG problem with a wkhtmltopdf command-line flag?

No. The documented SVG flags are limited to checkbox and radiobutton artwork; general SVG rendering requires testing the build, inclusion method and artwork features.

Is an SVG in the HTML guaranteed to remain vector in the PDF?

No. Reported wkhtmltopdf output has rasterized SVG artwork, so inspect the PDF when vector scalability is a requirement.

What is the safest fallback for a troublesome SVG?

Convert it separately with librsvg or CairoSVG, verify the converted output, and insert PDF or PNG according to the capabilities of your document pipeline.

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

Quick Recap

SaleBestseller No. 3
CNC Programming Handbook, Third Edition
CNC Programming Handbook, Third Edition
New; Mint Condition; Dispatch same day for order received before 12 noon; Guaranteed packaging
$98.00
Bestseller No. 4

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.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.