Reputation: 7719
I am trying to convert a local HTML to a PDF, but the html document has non-ASCII characters that end up broken in the PDF. Why does pisa
not work for all UTF-8 characters?
with open('file.html') as m:
data = m.read()
m.close()
pisa.CreatePDF(data, file('final.pdf', 'w'))
Upvotes: 1
Views: 3799
Reputation: 1549
For me it helped using the encoding option with encoding='utf-8':
pisa.CreatePDF(html.content, dest=pdfFile, encoding='utf-8')
Upvotes: 0
Reputation: 620
Got it. This needs to be at the top of your generated content:
<meta http-equiv="content-type" content="text/html; charset=utf-8">
Upvotes: 7