使用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)? –