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

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


I've figured out what the problem was/is. The data gets written into a
table cell that eventually becomes so long that it needs to stretch
across two pages. I'm now going to completely side-step the whole
problem but instead breaking it up into multiple cells or reconsider
the whole approach of using a table.

On 10 May 2010 00:32, Peter Bengtsson <peter at fry-it.com> wrote:

> 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

>    p.build(elements)

>  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

>    self.handle_flowable(flowables)

>  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']),

>                  assessor_strengths

>                 ]])

>

> 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":

> http://stackoverflow.com/questions/1842266/reportlab-layouterror-too-large-on-page

> http://two.pairlist.net/pipermail/reportlab-users/2004-November/003525.html

> 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

>




--
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