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

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


--KlAEzMkarCnErv5Q
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=
ial

  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"))
  canvas.save()

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

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/qXZvkVdEXeem148RAtEnAJ9mOvQYjXb7ppuEmM/mxlTM4OoBxwCeN4Hb
8oAuyDj1vfTupy0kkUmaYQ4=
=Ri1w
-----END PGP SIGNATURE-----

--KlAEzMkarCnErv5Q--