[reportlab-users] extra TTF font borks script

Reed L. O'Brien reed at intersiege.com
Sun Oct 29 12:01:31 EST 2006


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  
recent call last):, referer: http://http://someurl
[Sun Oct 29 11:43:48 2006] [error] [client 127.0.0.1]   File "/path/ 
to/script.py", line 97, in ?, referer: http://http://someurl
[Sun Oct 29 11:43:48 2006] [error] [client 127.0.0.1]     print  
c.getpdfdata(), referer: http://http://someurl
[Sun Oct 29 11:43:48 2006] [error] [client 127.0.0.1]   File "/usr/ 
local/lib/python2.4/site-packages/reportlab/pdfgen/canvas.py", line  
850, in getpdfdata, referer: http://http://someurl
[Sun Oct 29 11:43:48 2006] [error] [client 127.0.0.1]     return  
self._doc.GetPDFData(self), referer: http://http://someurl
[Sun Oct 29 11:43:48 2006] [error] [client 127.0.0.1]   File "/usr/ 
local/lib/python2.4/site-packages/reportlab/pdfbase/pdfdoc.py", line  
230, in GetPDFData, referer: http://http://someurl
[Sun Oct 29 11:43:48 2006] [error] [client 127.0.0.1]      
fnt.addObjects(self), referer: http://http://someurl
[Sun Oct 29 11:43:48 2006] [error] [client 127.0.0.1]   File "/usr/ 
local/lib/python2.4/site-packages/reportlab/pdfbase/ttfonts.py", line  
1099, in addObjects, referer: http://http://someurl
[Sun Oct 29 11:43:48 2006] [error] [client 127.0.0.1]      
pdfFont.ToUnicode = doc.Reference(cmapStream, 'toUnicodeCMap:' +  
baseFontName), referer: http://http://someurl
[Sun Oct 29 11:43:48 2006] [error] [client 127.0.0.1]   File "/usr/ 
local/lib/python2.4/site-packages/reportlab/pdfbase/pdfdoc.py", 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


More information about the reportlab-users mailing list