[reportlab-users] any help plz ....

Marius Gedminas reportlab-users@reportlab.com
Thu, 6 Nov 2003 00:15:11 +0200

Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Nov 05, 2003 at 01:41:09PM -0800, sarah el-lawindy wrote:
> dear Jerome Alet
>   hi , i know  u got very bored from my very very primitaive
>   questions, but i really need any help.
>   ok, do u know  anything about unicode thing? i tried to write a
>   unicode string, but the compiler gave me a error, "not a valid UTF-8
>   string" an then i tried another one (i got it from the mailing list
>   archive), but gave another error " something (i can't remeber) then
>   ordinal 128" . so do u know the solution for this ?

If you showed your code, it would be easier to see were the problem is.

This should work:

  from reportlab.pdfbase import pdfmetrics
  from reportlab.pdfbase.ttfonts import TTFont

  # Change this to where Arial.ttf lives
  fontdir =3D '/usr/share/fonts/truetype/'
  pdfmetrics.registerFont(TTFont('MyArial', fontdir + 'Arial.ttf'))
  # If I try to use just 'Arial', I get this error from reportlab
  # 1.18debian-1.1:
  # ValueError: _tt2ps_map[('arial', 1, 0)]=3D=3DArial-Bold already, not Ar=

  from reportlab.pdfgen.canvas import Canvas

  canvas =3D Canvas('foo.pdf')
  canvas.setFont('MyArial', 12)
  canvas.drawString(100, 700, u"Test: \u010A\u010B".encode("UTF-8"))

Marius Gedminas
I spent a lot of time in the Java world. I'm so glad I'm on Planet
Python now :-)
		-- Steve Alexander

Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

Version: GnuPG v1.2.3 (GNU/Linux)