Skip to content

[table] Feature request: support "colspanning-cells" breaking over page jumps #1460

@slkoo-cc

Description

@slkoo-cc
from fpdf import FPDF
from fpdf.enums import TableSpan

pdf = FPDF()

pdf.auto_page_break = True
pdf.set_font("Arial", size=12)
pdf.add_page()

data = [
    ["Header 1", "Header 2", "Header 3"],
    ["Data 1", "Data 2", "Data 3"],
] + [[TableSpan.ROW, "Data 5", "Data 6"]] * 50

with pdf.table(data) as table:
    pass

pdf.output("overly_long_tablespan.pdf")

raises

Traceback (most recent call last):
  File "c:\Users\User\Desktop\Platform-Integration\API\test_graph.py", line 14, in <module>
    with pdf.table(data) as table:
         ^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 144, in __exit__
    next(self.gen)
  File "C:\Users\User\Desktop\Platform-Integration\API\myvenv\Lib\site-packages\fpdf\fpdf.py", line 5602, in table
    table.render()
  File "C:\Users\User\Desktop\Platform-Integration\API\myvenv\Lib\site-packages\fpdf\table.py", line 257, in render
    raise ValueError(
ValueError: The row with index 1 is too high and cannot be rendered on a single page

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions