[reportlab-users] "Flowable too large" - how to KeepTogether

Peter Bengtsson peter at fry-it.com
Sun May 9 19:32:26 EDT 2010

I've inherited a piece of code that uses reportlab (2.4) to generate a
report containing a table. I get this error:

File "/home/peterbe/waf/assessment/utils.py", line 868, in EspratReportPdf
File "/home/peterbe/waf/reportlab/platypus/doctemplate.py", line
1110, in build
BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
File "/home/peterbe/waf/reportlab/platypus/doctemplate.py", line 877, in build
File "/home/peterbe/waf/reportlab/platypus/doctemplate.py", line
793, in handle_flowable
raise LayoutError(ident)
LayoutError: Flowable <Table at 0x0CED4EAC 2 rows x 3 cols> with
cell(0,0) containing
'<Paragraph at 0xcecf50c>Strength'(440 x 16777251) too large on page 5
in frame 'normal'(439.275590551 x 685.88976378*) of template 'Later'

After some digging I found that the culprit is around this code::

assessor_strengths = [Paragraph(x, styles['Normal'])
for x in assessor_strengths]

data.extend([[Paragraph(_('<b>Strength</b>'), styles['Normal']),
Paragraph(strength_self, styles['Normal']),

The variable assessor_strengths is a normal Python list of Unicode
strings escaped. Nothing fancy.
If I debug it like this::

print [len(x) for x in assessor_strengths]

The outcome becomes::

[179, 83, 93, 821, 79, 86, 89, 297, 126, 55, 159, 56]

That's a total of 2,123 characters. If I insert this line just before::

assessor_strengths = [x[:20] for x in assessor_strengths]

Then the rest of the code works. Clearly, inserting all these
paragraphs into a table cell pushes some limit but I really don't want
to change the data.
Searching I've found these "solutions":
But none help me.

How am I supposed to use this KeepTogether trick that appears to have
helped people in the past?

Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org

More information about the reportlab-users mailing list