Being a native danish speaker, we are blessed with three extra letters
:)
Working with pdfgen, i get
<code>
from reportlab.pdfgen import canvas
c = canvas.Canvas("C:\\mypdf.pdf")
c.setFont('Arial',12)
c.setFont('Helvetica',12)
c.drawString(10,10,'זרו')
</code>
but then, I get :
<error>
UnicodeError: ASCII encoding error: ordinal not in range(128)
</error>
How do I manage to get Latin-1 (or even better full unicode) support
in pdfgen ?
Svenne
>c.setFont('Arial',12)
Ups.. shouldn't have been there
ReportLab _is_ latin (1, 2, 9, 15...) compliant, it only needs unicode
string to be passed to text drawing routines. So:
c.drawString(10, 10, unicode('Zażółć gęślą jaźń'.decode('ISO8859-2')))
should write usual Polish compatibility test ;)
--
Jarek Zgoda
http://www.zgoda.biz/ JID:zg...@jabber.atman.pl
><code>
> from reportlab.pdfgen import canvas
> c = canvas.Canvas("C:\\mypdf.pdf")
> c.setFont('Arial',12)
> c.setFont('Helvetica',12)
> c.drawString(10,10,'æøå')
></code>
>
> but then, I get :
>
><error>
> UnicodeError: ASCII encoding error: ordinal not in range(128)
></error>
How about
#v+
>>> utf8 = lambda s: unicode(s, 'iso-8859-1').encode('utf-8')
>>> c.drawString(10, 10, utf8('frække frølår')
#v-
(substitute your input charset for 'iso-8859-1')?
// Klaus
--
><> vandag, môre, altyd saam
>c.drawString(10, 10, unicode('Zażółć gęślą jaźń'.decode('ISO8859-2')))
Still same error
>#v+
>
>>>> utf8 = lambda s: unicode(s, 'iso-8859-1').encode('utf-8')
>>>> c.drawString(10, 10, utf8('frække frølår')
>
>#v-
Still same error.
On Wed, 12 Mar 2003 21:47:24 +0100, Svenne Krap <usene...@krap.dk>
wrote:
>Hi - yes, it's me again :)
> Still same error
Are you sure there's nothing wrong with yout python setup?
It works here if I use
#v+
>>> c.drawString(10, 10, unicode('blåbærgrød', 'iso-8859-1'))
#v-
where 'iso-8859-1' is my input charset.
My environment:
#v+
$ python
Python 2.2.2 (#1, Jan 18 2003, 10:18:59)
[GCC 3.2.2 20030109 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
$
#v-
// Klaus
--
><> unselfish actions pay back better
> Does the #v- and #v+ do anything ?
They are "verbatim" marks for the slrnน newsreader.
> Maybe it's a problem with the windows version ?
> Maybe it's a locale-problem..
Yes, maybe.
// Klaus
>Hi - yes, it's me again :)
>
>Being a native danish speaker, we are blessed with three extra letters
>:)
>Working with pdfgen, i get
Well, I wrote pdfgen, and can tell you it doesn't DO Unicode
yet :-) If you pass in an 8-bit string, and the string matches
the encoding of the font, it should work. The default encoding
of the standard fonts is Latin-1.
Exactly what Python are you using? Did you download it
or could it be an in-house build? AFAIR there is a way to enable
'Unicode strings everywhere' either as a compiler option or in
the environment, but I'd have to look at the docs.
Can you just try executing this in a script (with no reportlab in
sight):
myString = 'זרו'
print myString
and see if you get an error?
Also try running reportlab/lib/codecharts.py like this:
C:\code\reportlab\lib>codecharts.py
saved codecharts.pdf
It should generate a PDF document with Latin-1 code
charts on page 1. If not let me know.
Best Regards,
Andy Robinson
(ReportLab Inc)