我需要将文本打印为PDF,但是我正在打印的文本不是ascii。根据我的代码输出,它会生成类似
的内容[] [] [] [] [] [] [](一个方框;))
我正在尝试弄清楚如何将非ascii文本打印到PDF。谢谢!
Enter any number : a
ERROR!! Kindly enter a number only! : a
Traceback (most recent call last):
File "<stdin>", line 3, in meh
ValueError: invalid literal for int() with base 10: 'a'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in meh
ValueError: invalid literal for int() with base 10: 'a'
答案 0 :(得分:0)
您使用的字体不支持韩文字符。 fpdf docs对韩文使用eunjin字体:
# Add a Alee Unicode font (uses UTF-8)
# General purpose Hangul truetype fonts that contain Korean syllable
# and Latin9 (iso8859-15) characters.
pdf.add_font('eunjin', '', 'Eunjin.ttf', uni=True)
pdf.set_font('eunjin', '', 14)
pdf.write(8, u'Korean: 안녕하세요')