[reportlab-users] UnicodeDecodeError with ReportLab 1.2

Nathan nathan.stocks at gmail.com
Wed Mar 7 17:51:35 EST 2007


I'm using ReportLab 1.2 (and have been for awhile) and have recently
encountered the following error which I haven't been able to work
around:

File "/sm/va/common/reporting.py", line 634, in job2pdf
job_template.build(story)
File "/usr/lib/python2.4/site-packages/reportlab/platypus/doctemplate.py",
line 644, in build
self.handle_flowable(flowables)
File "/usr/lib/python2.4/site-packages/reportlab/platypus/doctemplate.py",
line 562, in handle_flowable
if self.frame.add(f, self.canv, trySplit=self.allowSplitting):
File "/usr/lib/python2.4/site-packages/reportlab/platypus/frames.py",
line 124, in _add
w, h = flowable.wrap(aW, h)
File "/usr/lib/python2.4/site-packages/reportlab/platypus/tables.py",
line 791, in wrap
self._calc(availWidth, availHeight)
File "/usr/lib/python2.4/site-packages/reportlab/platypus/tables.py",
line 452, in _calc
self._calc_height(availHeight,availWidth,W=W)
File "/usr/lib/python2.4/site-packages/reportlab/platypus/tables.py",
line 407, in _calc_height
dW,t = self._listCellGeom(v,w,s)
File "/usr/lib/python2.4/site-packages/reportlab/platypus/tables.py",
line 295, in _listCellGeom
vw, vh = v.wrapOn(canv,aW, aH)
File "/usr/lib/python2.4/site-packages/reportlab/platypus/flowables.py",
line 108, in wrapOn
w, h = self.wrap(aW,aH)
File "/usr/lib/python2.4/site-packages/reportlab/platypus/paragraph.py",
line 420, in wrap
self.blPara = self.breakLines([first_line_width, later_widths])
File "/usr/lib/python2.4/site-packages/reportlab/platypus/paragraph.py",
line 563, in breakLines
for w in _getFragWords(frags):
File "/usr/lib/python2.4/site-packages/reportlab/platypus/paragraph.py",
line 198, in _getFragWords
n = n + stringWidth(w, f.fontName, f.fontSize)
File "/usr/lib/python2.4/site-packages/reportlab/pdfbase/pdfmetrics.py",
line 658, in _slowStringWidth
return font.stringWidth(text, fontSize)
File "/usr/lib/python2.4/site-packages/reportlab/pdfbase/ttfonts.py",
line 959, in stringWidth
for code in parse_utf8(text):
File "/usr/lib/python2.4/site-packages/reportlab/pdfbase/ttfonts.py",
line 80, in <lambda>
parse_utf8=lambda x, decode=utf_8_decode: map(ord,decode(x)[0])
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb0 in position 4:
unexpected code byte'


Any ideas? My best guess is that some funky character got into my
data somewhere. I haven't been able to identify where the character
is coming from, as I generate my PDF's from many sources.

~ Nathan


More information about the reportlab-users mailing list