本文介绍了用Python创建多语言PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好, 我正在与Pdf Unicode合作。我尝试使用ufpdf创建一个类但是有些字符不正确现在我想尝试Python因为 a朋友告诉我它非常强大。 br /> 我需要一个简单的Python脚本,从MySql 表中获取所有记录并在pdf文件中打印。 存储在我的数据库中的语言大约是25,它们是: 希腊语英语法语匈牙利语意大利语立陶宛语荷兰语葡萄牙语 阿尔巴尼亚语 捷克语丹麦语德语西班牙语爱沙尼亚语芬兰爱尔兰拉脱维亚语马耳他语 波兰语罗马尼亚语 俄语斯洛文尼亚语斯洛伐克语瑞典语 任何人都可以帮助我吗? 谢谢 Perseo 解决方案 您可以给reportlab [1] a尝试。它支持TrueType字体 和使用UTF-8进行unicode转换。我以前用它来制作pdf文件 和波兰字符。 一些示例代码: <代码> from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfgen import canvas pdfmetrics.registerFont(TTFont(''Verdana'',''Verdana.ttf'')) c = canvas.Canvas(" pl.pdf") b $ b c.setFont(" Verdana",12) c.drawString(100,600," Witaj,?wiecie!" .decode(" iso-) 8859-2")。encode(" utf-8")) c.showPage() c.save() < / code> [1] http://www.reportlab .org / - HTH, Rob 你可以给reportlab [1] a尝试。它支持TrueType字体 和使用UTF-8进行unicode转换。我以前用它来制作pdf文件 和波兰字符。 一些示例代码: <代码> from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfgen import canvas pdfmetrics.registerFont(TTFont(''Verdana'',''Verdana.ttf'')) c = canvas.Canvas(" pl.pdf") b $ b c.setFont(" Verdana",12) c.drawString(100,600," Witaj,?wiecie!" .decode(" iso-) 8859-2")。encode(" utf-8")) c.showPage() c.save() < / code> [1] http://www.reportlab .org / - HTH, Rob 你可以给reportlab [1] a尝试。它支持TrueType字体 和使用UTF-8进行unicode转换。我以前用它来制作pdf文件 和波兰字符。 一些示例代码: <代码> from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfgen import canvas pdfmetrics.registerFont(TTFont(''Verdana'',''Verdana.ttf'')) c = canvas.Canvas(" pl.pdf") b $ b c.setFont(" Verdana",12) c.drawString(100,600," Witaj,?wiecie!" .decode(" iso-) 8859-2")。encode(" utf-8")) c.showPage() c.save() < / code> [1] http://www.reportlab .org / - HTH, Rob Hi guys,I''m disprate with the Pdf Unicode. I try to create a class using ufpdfbut some chars are not correct and now I would like try Python becausea friend tolds me that it''s very powerful.I need a simple script in Python that grab all Records from a MySqltable and print in the pdf file.The languages stored in my db are about 25 and they are:Greek English French Hungarian Italian Lithuanian Dutch PortugueseAlbanianCzech Danish German Spanish Estonian Finnish Irish Latvian MaltesePolish RomanianRussian Slovene Slovak SwedishAnyone can help me, please?ThanksPerseo 解决方案You can give reportlab [1] a try. It has support for TrueType fontsand unicode translation using UTF-8. I used to use it for pdf fileswith polish chars.Some example code:<code>from reportlab.pdfbase import pdfmetricsfrom reportlab.pdfbase.ttfonts import TTFontfrom reportlab.pdfgen import canvaspdfmetrics.registerFont(TTFont(''Verdana'', ''Verdana.ttf''))c = canvas.Canvas("pl.pdf")c.setFont("Verdana", 12)c.drawString(100, 600, "Witaj, ?wiecie!".decode("iso-8859-2").encode("utf-8"))c.showPage()c.save()</code>[1] http://www.reportlab.org/--HTH,RobYou can give reportlab [1] a try. It has support for TrueType fontsand unicode translation using UTF-8. I used to use it for pdf fileswith polish chars.Some example code:<code>from reportlab.pdfbase import pdfmetricsfrom reportlab.pdfbase.ttfonts import TTFontfrom reportlab.pdfgen import canvaspdfmetrics.registerFont(TTFont(''Verdana'', ''Verdana.ttf''))c = canvas.Canvas("pl.pdf")c.setFont("Verdana", 12)c.drawString(100, 600, "Witaj, ?wiecie!".decode("iso-8859-2").encode("utf-8"))c.showPage()c.save()</code>[1] http://www.reportlab.org/--HTH,RobYou can give reportlab [1] a try. It has support for TrueType fontsand unicode translation using UTF-8. I used to use it for pdf fileswith polish chars.Some example code:<code>from reportlab.pdfbase import pdfmetricsfrom reportlab.pdfbase.ttfonts import TTFontfrom reportlab.pdfgen import canvaspdfmetrics.registerFont(TTFont(''Verdana'', ''Verdana.ttf''))c = canvas.Canvas("pl.pdf")c.setFont("Verdana", 12)c.drawString(100, 600, "Witaj, ?wiecie!".decode("iso-8859-2").encode("utf-8"))c.showPage()c.save()</code>[1] http://www.reportlab.org/--HTH,Rob 这篇关于用Python创建多语言PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-12 04:33