[reportlab-users] Paragraph split

Bzzz lazyvirus at gmx.com
Fri Feb 10 17:05:12 EST 2012


Hi,

I'm trying to understand how to split a high paragraph but there's
something I don't understand split. From what I understand from RL
code it should return 2 other paragraphs.
But when I try to draw the 1st one it fails:(

def test():
styles = getSampleStyleSheet()
mystyle = ParagraphStyle(name='abc',
parent=styles['Normal'],
fontSize=9,
leading=11,
alignment=TA_JUSTIFY,
bulletFontSize=9,
bulletText="•",
autoLeading='min')

c = Canvas("paragraph_split.pdf",verbosity=1)

para = Paragraph("Lorem ipsum dolor sit amet, consectetur adipisicing \
elit, sed do eiusmod tempor incididunt ut labore et dolore magna \
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco \
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure \
dolor in reprehenderit in voluptate velit esse cillum dolore eu \
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non \
proident, sunt in culpa qui officia deserunt mollit anim id est \
laborum.\n" * 15,
mystyle)

X = 6*cm
Y = 1*cm

aW = 4*cm
aH = 5*cm

paralist = para.split( aW, aH )

i = 1
for p in paralist:
p.drawOn( c, X, Y*i )
i += 1

c.save()


I get that:

Traceback (most recent call last):
File "example2_flowable_03_chgt_split_AVANT_wrap.py", line 57, in <module>
test()
File "example2_flowable_03_chgt_split_AVANT_wrap.py", line 49, in test
p.drawOn( c, X, Y*i )
File "/usr/lib/python2.7/dist-packages/reportlab/platypus/flowables.py", line 108, in drawOn
self._drawOn(canvas)
File "/usr/lib/python2.7/dist-packages/reportlab/platypus/flowables.py", line 89, in _drawOn
self.draw()#this is the bit you overload
File "/usr/lib/python2.7/dist-packages/reportlab/platypus/paragraph.py", line 992, in draw
self.drawPara(self.debug)
File "/usr/lib/python2.7/dist-packages/reportlab/platypus/paragraph.py", line 1416, in drawPara
cur_y = self.height - f.fontSize
AttributeError: 'tuple' object has no attribute 'fontSize'

Jiff
--
How can you work when the system's so crowded?


More information about the reportlab-users mailing list