我正在尝试将本地HTML转换为PDF,但html文档包含非ASCII字符,这些字符最终在PDF中断开。为什么pisa不适用于所有的UTF-8字符?
with open('file.html') as m:
data = m.read()
m.close()
pisa.CreatePDF(data, file('final.pdf', 'w'))发布于 2013-02-08 05:32:36
明白了。这需要放在您生成的内容的顶部:
<meta http-equiv="content-type" content="text/html; charset=utf-8"> 发布于 2015-03-30 01:57:01
对我来说,在encoding='utf-8'中使用编码选项很有帮助
pisa.CreatePDF(html.content, dest=pdfFile, encoding='utf-8')https://stackoverflow.com/questions/12185464
复制相似问题