[reportlab-users] Possible bug with CJK wrapping?

Roberto Alsina ralsina at netmanagers.com.ar
Fri Jun 17 10:24:41 EDT 2011


I have not done a pure-reportlab test for this bug reported against
rst2pdf but it does seem to me like a reportlab bug.

The gist is something like this: with a document that has very long
lines, some in english, some in chinese, if you set a paragraph in
english to CJK word wrapping (which I know is wrong ;-) you get this
exception:

Traceback (most recent call last):
File "/usr/bin/rst2pdf", line 9, in <module>
load_entry_point('rst2pdf==0.17.dev-r2435', 'console_scripts',
'rst2pdf')()
File
"/home/ralsina/Desktop/proyectos/rst/trunk/rst2pdf/createpdf.py", line
1468, in main
compressed=options.compressed)
File
"/home/ralsina/Desktop/proyectos/rst/trunk/rst2pdf/createpdf.py", line
672, in createPdf
pdfdoc.multiBuild(elements)
File
"/usr/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/platypus/doctemplate.py",
line 960, in multiBuild
self.build(tempStory, **buildKwds)
File
"/usr/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/platypus/doctemplate.py",
line 880, in build
self.handle_flowable(flowables)
File
"/home/ralsina/Desktop/proyectos/rst/trunk/rst2pdf/createpdf.py", line
780, in handle_flowable
if frame.add(f, canv, trySplit=self.allowSplitting):
File
"/home/ralsina/Desktop/proyectos/rst/trunk/rst2pdf/flowables.py", line
552, in add
return Frame.add(self, flowable, canv, trySplit)
File
"/usr/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/platypus/frames.py",
line 174, in _add
flowable.drawOn(canv, self._x + self._leftExtraIndent, y, _sW=aW-w)
File
"/usr/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/platypus/flowables.py",
line 108, in drawOn
self._drawOn(canvas)
File
"/usr/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/platypus/flowables.py",
line 89, in _drawOn
self.draw()#this is the bit you overload
File
"/usr/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/platypus/paragraph.py",
line 993, in draw
self.drawPara(self.debug)
File
"/usr/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/platypus/paragraph.py",
line 1459, in drawPara
dpl( tx, offset, lines[0], noJustifyLast and nLines==1)
File
"/usr/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/platypus/paragraph.py",
line 336, in _justifyDrawParaLineX
simple = last or abs(extraSpace)<=1e-8 or line.lineBreak
AttributeError: FragLine instance has no attribute 'lineBreak'


Here is the problematic FragLine:

FragLine(ascent=7.59765625, descent=-2.40234375,
extraSpace=2.1798028420274136, fontSize=10.0, kind=1, wordCount=1,
words=[ABag(bold=0, cbDefn=ABag(kind='anchor', label='anchor',
name='test'), fontName='DejaVuSans', fontSize=10.0, greek=0, italic=0,
link=None, rise=0, strike=0, sub=0, super=0, text=u'',
textColor=Color(0,0,0,1), underline=0), ABag(bold=0,
fontName='DejaVuSans', fontSize=10.0, greek=0, italic=0, link=None,
rise=0, strike=0, sub=0, super=0, text=u'a very long english sentence a
very long english sentence a very long english sentence a very',
textColor=Color(0,0,0,1), underline=0)])




More information about the reportlab-users mailing list