[reportlab-users] How to change PDF document encoding to iso-8859-15
eafgan at emory.edu
Wed Jan 19 22:58:13 EST 2011
I'm getting familiar with ReportLab but I ran into an issue I haven't been
able to resolve for a few of hours now so I decided to ask here.
I need to generate PDF documents using iso-8859-15 (latin-9) encoding but
it's just not happening. I'm running OSX 10.6.6 with Python 2.7 and
ReportLab 2.5. The documents are being generated from within a Django (v1.3)
app and here is the relevant view code:
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=file.pdf'
p = canvas.Canvas(response)
x = u"četvrtak"
y = "šteta"
p.drawString(100, 780, x.encode('iso-8859-15'))
p.drawString(100, 780, y)
Here is a screenshot of the resulting PDF:
If I just print to the terminal x.encode('iso-8859-15'), the outcome is as
It seems that the reason 'š' is printing fine is because it's part of the
WinAnsi encoding while 'č' is not but anything else I've tried did not work.
I tried using utf-8 and couple other encodings, but to no avail...
Any suggestions would be greatly appreciated,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the reportlab-users