[reportlab-users] extra TTF font borks script

Robin Becker robin at reportlab.com
Sun Oct 29 14:03:05 EST 2006


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 (most 
y",
> 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: 
> http://http://someurl
> [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, height=None)
>     c.drawImage(sig, 2.75 * inch, 3.5 * inch, width=None, height=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.drawText(to)
> c = canvas.Canvas('/tmp/temp.pdf', pagesize=(8.5 * inch, 11 * inch))
> go(c)
> c.showPage()
> c.save()
> print c.getpdfdata()
> sys.exit(0)
> 
> 
> 
> ~reed

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


More information about the reportlab-users mailing list