wkhtmltopdf / wkhtmltopdf

Convert HTML to PDF using Webkit (QtWebKit)
https://wkhtmltopdf.org
GNU Lesser General Public License v3.0
13.99k stars 1.83k forks source link

wkhtmltopdf missing SVG paths (Rendering) #3890

Open iuryt opened 6 years ago

iuryt commented 6 years ago

I'm using a image inside the HMTL code like here below:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Test</title>
  </head>
  <body>
    <svg height="291pt" version="1.1" viewBox="0 0 291 291" width="291pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs>  <style type="text/css">*{stroke-linecap:butt;stroke-linejoin:round;}  </style> </defs> <g id="figure_1">  <g id="patch_1">   <path d="M 0 291.4 L 291.4 291.4 L 291.4 0 L 0 0 z" style="fill:none;"></path>  </g>  <g id="axes_1">   <g id="line2d_1">    <path clip-path="url(#p6e64365aaf)" d="M 268.427273 145.7 L 207.063636 251.984936 " style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.2;"></path>   </g>   <g id="line2d_2">    <path clip-path="url(#p6e64365aaf)" d="M 248.397453 148.307103 L 199.306544 233.335052 " style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.2;"></path>   </g>   <g id="line2d_3">    <path clip-path="url(#p6e64365aaf)" d="M 207.063636 251.984936 L 84.336364 251.984936 " style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.2;"></path>   </g>   <g id="line2d_4">    <path clip-path="url(#p6e64365aaf)" d="M 84.336364 251.984936 L 22.972727 145.7 " style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.2;"></path>   </g>   <g id="line2d_5">    <path clip-path="url(#p6e64365aaf)" d="M 92.093456 233.335052 L 43.002547 148.307103 " style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.2;"></path>   </g>   <g id="line2d_6">    <path clip-path="url(#p6e64365aaf)" d="M 22.972727 145.7 L 84.336364 39.415064 " style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.2;"></path>   </g>   <g id="line2d_7">    <path clip-path="url(#p6e64365aaf)" d="M 84.336364 39.415064 L 207.063636 39.415064 " style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.2;"></path>   </g>   <g id="line2d_8">    <path clip-path="url(#p6e64365aaf)" d="M 96.609091 55.457845 L 194.790909 55.457845 " style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.2;"></path>   </g>   <g id="line2d_9">    <path clip-path="url(#p6e64365aaf)" d="M 207.063636 39.415064 L 268.427273 145.7 " style="fill:none;stroke:#000000;stroke-linecap:square;stroke-width:1.2;"></path>   </g>  </g> </g> <defs>  <clipPath id="p6e64365aaf">   <rect height="270" width="270" x="10.7" y="10.7"></rect>  </clipPath> </defs></svg>
  </body>
</html>

StackOverflow question (in Bounty): https://stackoverflow.com/questions/49986959/wkhtmltopdf-missing-svg-paths-rendering

When I'm using the wkhtmltopdf to convert it to PDF, some of the SVG paths is missing. Has anyone had the same problem? Some workaround to this issue?

I tried using the relative path, full path, base64 source and the SVG by itself within the code (as in the example).

wkhtmltopdf version: 0.12.4

Before: before After: after

ashkulz commented 6 years ago

Does it work with 0.13?

iuryt commented 6 years ago

Thanks for the suggestion. I'll try it.

The 0.13 version is only available on BitBucket? There's some other way to install it rather than manually build it? (pip or conda).

simon-raynor commented 6 years ago

I've just tried downloading the alpha build from the website and it seems to have resolved this issue (not the original poster but I was having very similar symptoms re: horizonal lines in SVGs)

xufeipyxis commented 6 years ago

v0.13-alpha fixed a similar issue for me: horizontal lines are missing in pdf.

do-web commented 6 years ago

Optimize your svg with this tool https://jakearchibald.github.io/svgomg/ then all path are rendered, for me that worked.

arpit87 commented 6 years ago

SVG paths are working for 0.13 but the --footer-html tag is not working.

bhavinzwt commented 4 years ago

How can we get the 0.13 version of the wkhtmltopdf? Because I am not able to find from the website: https://wkhtmltopdf.org/downloads.html