[reportlab-users] keepWithNext problem

Wietse Jacobs W.Jacobs at intersentia.be
Fri Nov 2 12:38:48 EDT 2007


Hello,

First of all, thanks for a great toolkit! I've only recently started
using ReportLab so I'm still trying to figure things out.

I've isolated a problem that I have. When I execute the following
script:
-----------------------------------------------------------
from reportlab.platypus import *
from reportlab.lib.styles import ParagraphStyle
from reportlab.graphics.shapes import Drawing, Rect


normal = ParagraphStyle(name='Normal',
fontName='Helvetica',
fontSize=8.5,
leading=11)

header = ParagraphStyle(name='Heading1',
parent=normal,
fontSize=14,
leading=19,
spaceAfter=6,
keepWithNext=1)

d = Drawing(400, 200)
d.add(Rect(50, 50, 300, 100))

story = [Paragraph("The section header", header), d]

doc = SimpleDocTemplate('test.pdf')
doc.build(story)
-----------------------------------------------------------

I get the following Traceback:
-----------------------------------------------------------
Traceback (most recent call last):
File "TestDrawing.py", line 30, in <module>
doc.build(story)
File
"C:\Python25\lib\site-packages\reportlab\platypus\doctemplate.py", line
911, in build
BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
File
"C:\Python25\lib\site-packages\reportlab\platypus\doctemplate.py", line
740, in build
self.handle_flowable(flowables)
File
"C:\Python25\lib\site-packages\reportlab\platypus\doctemplate.py", line
620, in handle_flowable
self.handle_keepWithNext(flowables)
File
"C:\Python25\lib\site-packages\reportlab\platypus\doctemplate.py", line
601, in handle_keepWithNext
f.keepWithNext = 0
File "C:\Python25\lib\site-packages\reportlab\graphics\shapes.py",
line 299, in __setattr__
validateSetattr(self,attr,value) #from reportlab.lib.attrmap
File "C:\Python25\lib\site-packages\reportlab\lib\attrmap.py", line
88, in validateSetattr
raise AttributeError, "Illegal attribute '%s' in class %s" % (name,
obj.__class__.__name__)
AttributeError: Illegal attribute 'keepWithNext' in class Drawing
-----------------------------------------------------------

This happens when in the sequence of flowables there is a `Paragraph`
(with `keepWithNext`=1) that is followed by a `Drawing`. There is no
problem with the other flowables I use (`Table`s and `Paragraph`s).
Should I wrap the drawing in some other flowable?

Thanks for your time,
Wietse Jacobs


More information about the reportlab-users mailing list