wkhtmltopdf failure when embed an SVG

前端 未结 4 530
-上瘾入骨i
-上瘾入骨i 2020-12-17 14:27

Has anyone in this vast space has ever had the luck to successfully create a PDF with an embedded SVG on an HTML? I\'ve been receiving segmentation fault all the time.

4条回答
  •  一生所求
    2020-12-17 15:01

    I had similar problem. Seems like javascript embedded in SVG image can cause segmentation fault.

    I was generating SVG graphs using pygal Python module. To successfully generate PDF from HTML with SVG graphs I had to do several things:

    1. Remove reference to javascript. (In case of pygal add js=() key to a graph constructor).
    2. Specify image size in svg tag, like

      
      

      (In case of pygal use explicit_size keywoard)

    3. Embed SVG image into img tag in base64 encoded form, like

      
      

    I was using 11th version of wkhtmltopdf.

提交回复
热议问题