Skip to content

Support rowspans taller than one page (#1460)#1820

Draft
jjudyyang wants to merge 4 commits into
py-pdf:masterfrom
jjudyyang:issue-1460-rowspan-page-break
Draft

Support rowspans taller than one page (#1460)#1820
jjudyyang wants to merge 4 commits into
py-pdf:masterfrom
jjudyyang:issue-1460-rowspan-page-break

Conversation

@jjudyyang
Copy link
Copy Markdown

@jjudyyang jjudyyang commented Apr 16, 2026

  • Fixes #1460: tables where a rowspan is taller than a single page no longer raise ValueError; the span is drawn in per-row slices across pages (with borders extended through row gutters so vertical lines stay continuous).
  • Fixes a blank first page when the first body row starts a very tall rowspan: the issue #1391 “heading + next row” pre-check now uses the same capped height as the main row loop (_pagebreak_space_before_row), instead of the full accumulated pagebreak_height of the entire rowspan.
  • Preserves old behaviour when the full rowspan still fits on one page: single merged rectangle path via _rowspan_merged_single_pass.
  • Still raises ValueError when a single row is taller than the usable page (test_table_with_very_long_text).

Tests

  • New / updated golden PDFs under test/table/ for multipage rowspan, repeated headings, and long text in a merged cell.
  • Existing rowspan + pagebreak tests kept green.

Checklist:

  • A unit test is covering the code added / modified by this PR

Happy to add docs if this looks correct

  • In case of a new feature, docstrings have been added, with also some documentation in the docs/ folder

  • A mention of the change is present in CHANGELOG.md

  • This PR is ready to be merged

By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.

Copy link
Copy Markdown
Collaborator

@andersonhc andersonhc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have 3 files lingering at the root level of the project (overly_long_tablespan_29.pdf, overly_long_tablespan_30.pdf and repro_tablespan.py) please remove them or rewrite as tests if you judge they are relevant.

with pdf.table(data, first_row_as_headings=False):
pass
assert_pdf_equal(
pdf, HERE / "table_rowspan_issue_1460_merged_cell_long_text_no_header.pdf", tmp_path
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actions pipeline is failing because this file has not been commited.

Comment on lines +246 to +259
def test_table_rowspan_issue_1460_repeat_headings(tmp_path):
# Same as multipage case, but headings must repeat after each page break.
pdf = FPDF()
pdf.auto_page_break = True
pdf.set_font("Helvetica", size=12)
pdf.add_page()
with pdf.table(
_issue_1460_table_data(30),
repeat_headings=TableHeadingsDisplay.ON_TOP_OF_EVERY_PAGE,
):
pass
assert_pdf_equal(
pdf, HERE / "table_rowspan_issue_1460_repeat_headings.pdf", tmp_path
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test and test_table_rowspan_issue_1460_multipage() seem to produce identical files - you could even reference the same PDF. Maybe the idea was to test TableHeadingsDisplay.NONE to cover both paths?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants