[reportlab-users] extra TTF font borks script
Reed L. O'Brien
reed at intersiege.com
Sun Oct 29 23:44:24 EST 2006
On Oct 29, 2006, at 5:34 PM, Reed L. O'Brien wrote:
>> Reed L. O'Brien wrote:
>>> It doesn't work with anything in the reportlab/font directory.
>>> Is there a better way to send a PDF through a cgi script other
>>> that getpdfdata()?
>>> What I am getting:
>>> [Sun Oct 29 11:43:48 2006] [error] [client 127.0.0.1] Traceback
>>> line 459, in Reference, referer: http://http://someurl
>>> [Sun Oct 29 11:43:48 2006] [error] [client 127.0.0.1] raise
>>> ValueError, "redefining named object: "+repr(name), referer:
>>> [Sun Oct 29 11:43:48 2006] [error] [client 127.0.0.1] ValueError:
>>> redefining named object: 'toUnicodeCMap:AAAAAA+Verdana-Bold',
>>> referer: http://someurl
>>> What I am doing (it works with Helvetica):
>>> import cgi, sys
>>> from reportlab.pdfgen import canvas
>>> from reportlab.lib.units import inch
>>> from reportlab.lib.pagesizes import letter
>>> from reportlab.pdfbase import pdfmetrics
>>> from reportlab.pdfbase.ttfonts import TTFont
>>> pdfmetrics.registerFont(TTFont('Verdana', 'verdana.ttf'))
>>> def go(c):'''draws the images and text'''
>>> c.drawImage(footer, 4 * inch, .375 * inch, width=None,
>>> c.drawImage(sig, 2.75 * inch, 3.5 * inch, width=None,
>>> c.drawImage(sidebar, .5 * inch, .375 * inch, width=2 * inch,
>>> height=8.625 * inch)
>>> c.drawImage(header, .5 * inch, 9.325 * inch, width=7.375 *
>>> inch, height=1.375 * inch)
>>> to = c.beginText() # instantiate a text object
>>> to.setTextOrigin(2.75 * inch, 8 * inch)
>>> to.setFont("Verdana", 10)
>>> for line in txt:
>>> to.textLine("%s" % line)
>>> c = canvas.Canvas('/tmp/temp.pdf', pagesize=(8.5 * inch, 11 * inch))
>>> print c.getpdfdata()
> On Oct 29, 2006, at 2:03 PM, Robin Becker wrote:
>> Does your python get invoked with the -u option (I am assuming
>> this is win32 of some kind because of the font name verdana).
>> Robin Becker
> No, it is on Linux2 (Fedora Core 3). The verdana font was bought
> for a previous project.
> I am not sure if I need to innvoke with -u flag. I will look at
> that and apache to find out and try it.
> It works fine with built in fonts, but not any that are registered.
> I have thought about storing the file in a StringIO object...
> I don't know if that would help.
OK, adding the -u flag to the #! line doesn't help.
I have also reproduced the error on a Mac G4 PB without CGI.
I used the same ttf from the linux box and also tried a ttf from a
I also tried it with StringIO but it didn't help me at all, but it
does save me having a tempfile on disk.
Any more ideas?
Maybe Ill try reading through pdfdoc and ttfonts when I have some
More information about the reportlab-users