Foreign language support for HTML to PDF conversion by weasyprint

987 Views Asked by At

I Have an HTML code in which some texts are in the Hindi language. When I am converting the HTML file to PDF using weasyprint library, The generated PDF looks something like this:

enter image description here

This is my code for conversion:

from weasyprint import HTML
output = open('kt.html', 'rb')#, encoding='utf-8')
html = HTML(output)
html.write_pdf(target='ouput.pdf')

Tried using encoding also, but got this error:

TypeError: Cannot set an encoding with a unicode input, set ['override_encoding', 'transport_encoding']

How to solve this issue?

EDIT: HTML code looks something like this: enter image description here

and HTML browser preview looks something like this

enter image description here

0

There are 0 best solutions below