Unicode characters are boxes in generated PDF

238 views
Skip to first unread message

Adam Neumann

unread,
Aug 30, 2011, 8:27:20 PM8/30/11
to geraldo-users
I'm running into some Unicode related issues when generating PDF
reports using Geraldo and ReportLab.

When Unicode strings containing Asian characters are passed into the
report, they appear in the output PDF as black boxes. This example
(http://dl.dropbox.com/u/2627296/report.pdf) was generated using the
following code:

#!/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')


I'm using Python 2.7.1, Geraldo 0.4.14 and ReportLab 2.5. System is
Ubuntu 11.04 64-bit. The .oy file is also UTF-8 encoded. The black
boxes are visible when the PDF is viewed in Document Viewer 2.32.0,
Okular 0.12.2 and Adobe Reader 9.

Any help is greatly appreciated, thanks.

musa fedakar

unread,
Aug 31, 2011, 11:22:16 AM8/31/11
to gerald...@googlegroups.com
hello adam
have u tried this example for additional fonts to print unicode characters?


be sure that u add ur asian fonts with this method.


--
Você está recebendo esta mensagem porque se inscreveu no grupo "geraldo-users" dos Grupos do Google.
Para postar neste grupo, envie um e-mail para gerald...@googlegroups.com.
Para cancelar a inscrição nesse grupo, envie um e-mail para geraldo-user...@googlegroups.com.
Para obter mais opções, visite esse grupo em http://groups.google.com/group/geraldo-users?hl=pt-BR.


Adam Neumann

unread,
Aug 31, 2011, 11:32:14 PM8/31/11
to geraldo-users
Thanks for the reply Musa. A similar conclusion was reached on the
stack overflow post (http://stackoverflow.com/questions/7251211/
unicode-characters-are-boxes-in-geraldo-reportlab-generated-pdf) for
this question.

Now the pdf is showing the right characters when a specific language's
font is specified. Ultimately I'm looking for a font that will work
for all ALL languages and is Linux compatible.

What font would you recommend using?

Thanks again.

On Sep 1, 1:22 am, musa fedakar <musafeda...@gmail.com> wrote:
> hello adam
> have u tried this example for additional fonts to print unicode characters?
>
>    -http://www.geraldoreports.org/docs/examples/additional-fonts.html
Reply all
Reply to author
Forward
0 new messages