使用Geraldo和ReportLab生成PDF报告时遇到了一些Unicode相关的问题。Unicode字符是在Geraldo/ReportLab中生成的PDF格式的PDF
如果将包含亚洲字符的Unicode字符串传递到报告中,它们将作为黑盒出现在输出PDF中。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from geraldo import Report, ReportBand, ObjectValue
from geraldo.generators import PDFGenerator
class UnicodeReport(Report):
title = 'Report'
class band_detail(ReportBand):
elements = [ObjectValue(attribute_name='name')]
if __name__ == '__main__':
objects = [{'name': u'한국어/조선말'}, {'name': u'汉语/漢語'}, {'name': u'オナカップ'}]
rpt = UnicodeReport(queryset=objects)
rpt.generate_by(PDFGenerator, filename='/tmp/report.pdf')
我使用Python 2.7.1,杰拉尔0.4.14和ReportLab的:使用以下代码生成该示例(http://dl.dropbox.com/u/2627296/report.pdf) 2.5。系统是Ubuntu 11.04 64位。 .oy文件也是UTF-8编码的。在Document Viewer 2.32.0,Okular 0.12.2和Adobe Reader 9中查看PDF时,可以看到黑匣子。
任何帮助非常感谢,谢谢。
您是否在使用[嵌入字体](http://forums.adobe.com/thread/370548)?您正在测试的机器上是否安装了[亚洲字体包](http://help.adobe.com/zh_CN/Acrobat/9.0/Standard/WSDCD9813D-3347-4781-810C-5DE967647580.w.html)? –