Reportlab platypus - disable table splitting

I am doing a dynamically generated report in python using Reportlab Platypus.

I have several tables that are generated, most have just 10 to 20 rows. Now they are automatically split at the end of my page, but I would prefer that they stay together on the same page.

I tried setting splitByRow to False on Table, but this causes a "Not implemented" error.

Also, I am not allowed to make any changes to the python reportLab files, although I can see the code. Maybe I can subclass the table and disable the split somehow?

What is the easiest way to disable the current split?

+4
source share
1 answer

I found the answer myself. I import KeepTogether from reportlab.platypus.flowables, and then when I add the table to the list of items, I use KeepTogether, for example:

from reportlab.platypus.flowables import KeepTogether t = Table(tableData) self.elements[name] = KeepTogether(t) 
+3
source

All Articles