[reportlab-users] Barcode Bug?
John Keyes
johnkeyes at gmail.com
Fri May 22 20:58:07 EDT 2009
Hi,
This is my first post so please be gentle :)
I think I've found a bug in the barcode code.
The following code:
barcode=code39.Standard39("xxx",
barWidth=0.275*mm,
barHeight=10*mm,
ratio=2.3,
humanReadable=True)
barcode.drawOn(canvas, x, y)
raise the following error:
barcode.drawOn(canvas, x, y)
File "site-packages/reportlab/platypus/flowables.py", line 105, in drawOn
self._drawOn(canvas)
File "site-packages/reportlab/platypus/flowables.py", line 89, in _drawOn
self.draw()#this is the bit you overload
File "site-packages/reportlab/graphics/barcode/common.py", line 146,
in draw
self.drawHumanReadable()
File "site-packages/reportlab/graphics/barcode/common.py", line 164,
in drawHumanReadable
self.annotate(x+width/2.,-y,s,fontName,fontSize)
File "site-packages/reportlab/graphics/barcode/common.py", line 176,
in annotate
getattr(canv,func)(text,x,y)
File "site-packages/reportlab/pdfgen/canvas.py", line 1287, in
drawCentredString
width = self.stringWidth(text, self._fontname, self._fontsize)
File "site-packages/reportlab/pdfgen/canvas.py", line 1392, in
stringWidth
(fontSize,self._fontsize)[fontSize is None])
File "site-packages/reportlab/pdfbase/pdfmetrics.py", line 718, in
_py_stringWidth
return getFont(fontName).stringWidth(text, fontSize, encoding=encoding)
File "site-packages/reportlab/pdfbase/pdfmetrics.py", line 402, in
_py_stringWidth
if not isinstance(text,unicode): text = text.decode(encoding)
AttributeError: 'float' object has no attribute 'decode'
To prevent this error I changed line 176 in
reportlab/graphics/barcode/common.py from:
getattr(canv,func)(text,x,y)
to:
getattr(canv,func)(x,y,text)
Do you need a patch and test etc. for this?
Thanks,
-John K
More information about the reportlab-users
mailing list