Table cell (SPAN) across pagebreak

35 views
Skip to first unread message

Kyle Dunaway

unread,
Mar 9, 2018, 7:32:05 PM3/9/18
to reportlab-users
I have attached a simple example that should explain my larger problem.
I am creating a table, and as I am creating the table I am reducing redundancy in the table columns (if the cell above has the same word, leave cell empty)

If one table cell is larger than a whole page, ReportLab fails to generate the PDF.

On line 28, adjust the span length and you will see what I am talking about.

I have spend some time looking around and this problem seems to have not been fixed for a long time.

The workarounds I found seem pretty ugly (making the PDF 1 page, but then printing is out of the question)

Anyone have any idea on a fix?

Thanks for reading.
test.py

Niktsar Night

unread,
Jun 2, 2025, 11:12:53 PMJun 2
to reportlab-users
This issue is still not fixed as of version 4.4.1.
Minimal reproduction code:

```py
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle

# Create the document
doc = SimpleDocTemplate("overly_long_tablespan.pdf")

table_data = [
    ["Header 1", "Header 2", "Header 3"],
    ["Data 1", "Data 2", "Data 3"],
] + [["", "Data 4", "Data 5"]] * 50

# Create a Table object
tbl = Table(table_data)

style = TableStyle([
    ('SPAN', (0, 2), (0, len(table_data) - 1)),
])
tbl.setStyle(style)

# Build PDF
doc.build([tbl])

```
raises
```
Traceback (most recent call last):
  File "c:\Users\User\Desktop\API\test_pdf.py", line 20, in <module>
    doc.build([tbl])
  File "C:\Users\User\Desktop\API\myvenv\Lib\site-packages\reportlab\platypus\doctemplate.py", line 1322, in build
    BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
  File "C:\Users\User\Desktop\API\myvenv\Lib\site-packages\reportlab\platypus\doctemplate.py", line 1083, in build
    self.handle_flowable(flowables)
  File "C:\Users\User\Desktop\API\myvenv\Lib\site-packages\reportlab\platypus\doctemplate.py", line 962, in handle_flowable
    raise LayoutError(ident)
reportlab.platypus.doctemplate.LayoutError: Flowable <Table@0x229C5A6CFE0 50 rows x 3 cols(tallest row 18)> with cell(0,1) containing      
'Data 4'(159.39000000000001 x 900), tallest cell 18.0 points,  too large on page 2 in frame 'normal'(439.27559055118115 x 685.8897637795277*) of template 'Later'
```
Reply all
Reply to author
Forward
0 new messages