0

I am trying to convert a HTML to PDF using wkhtmltopdf and pdfkit with python. In my HTML, there is a circular text which is not getting rendered in pdf. But it's displaying in all browser. Everything else is rendering correctly.

Sample HTML

https://codepen.io/gmtek/pen/yLxJBMB

The section which is not rendered is:

<div class="date">
    <svg class="date-svg" viewBox="0 0 200 200" width="200px" height="200px">
        <defs>
            <path id="circle" d="M15,100 a 85,85 0 1,0 170,0" />
        </defs>
        <text>
            <textPath xlink:href="#circle">
                22.02.2023
            </textPath>
        </text>
    </svg>
</div>
                

And my python code to generate pdf:

import os
import pdfkit

def generate_local():
    config = pdfkit.configuration(wkhtmltopdf="/usr/local/bin/wkhtmltopdf")
    options = {
        'page-height': '55mm',
        'page-width': '55mm',
        'dpi': 300,
        'margin-top': '1mm',
        'margin-left': '0mm',
        'margin-right': '0mm',
        'margin-bottom': '0mm',
        'encoding': "UTF-8",
    }
    pdfkit.from_file('templates/sample.html', 'output.pdf',
                     configuration=config, options=options)

generate_local()
gmtek
  • 741
  • 3
  • 7
  • 25

0 Answers0