请教一下,下面代码生成的 pdf 是乱码,环境为 python3+windowns 10
谢谢大家!
import fitz
ofn = '3.pdf'
b = "你好! hello !"
width, height = fitz.PaperSize("a4")
fontsz = 10
lineheight = fontsz * 1.2
ffile = "C:/windows/fonts/consola.ttf"
font = "F0"
doc = fitz.open()
doc.insertPage(-1, fontsize = fontsz, text = b, fontname = font, fontfile = ffile, width = width, height = height)
doc.save(ofn, garbage=4, deflate=True)
doc.close()
1
sky395 OP 召唤大神 ing........
|
2
manzhiyong 2017-11-13 17:57:48 +08:00 1
用 reportlab 吧,reportlab 找个中文的 ttf 字体,指定下路径,是可以正常输出中文的,pymupdf 好像有 bug
|