Skip to content

Conversation

@Neyhlo
Copy link

@Neyhlo Neyhlo commented Dec 8, 2025

Fixes #1460 ---

What changes are being made?

This PR fixes a bug where tables containing large vertically spanned cells (rowspan) would crash when exceeding the page height, and allows them to break across pages cleanly.

Key changes:

  1. The restrictive ValueError check in Table.render() that prevented long rows from rendering is removed.
  2. Introduced a helper function (_get_span_origin) and logic in _render_table_row to draw the vertical borders for spanned cells on continuation pages (the "ghost borders").

Checklist:

  • A unit test is covering the code added / modified by this PR
    (Note: We verified this by running existing rowspan tests which fail without the fix.)

  • In case of a new feature, docstrings have been added, with also some documentation in the docs/ folder (N/A, this is a bug fix/enhancement to existing feature)

  • This PR is ready to be merged


Additional comments:

The change in functionality requires updating several golden PDF files in the test suite. Specifically, tests in test_table_rowspan.py and test_table_padding.py fail because the visual output now includes the vertical borders on continuation pages, which changes the MD5 hash.

The reference files (golden files) need to be updated to match the new, correct behavior.


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

@Neyhlo Neyhlo changed the title change on fpdf/table.py Fix: Support rowspans breaking over page jumps (#1460) Dec 8, 2025
Copy link
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.

Can you please add some tests for your feature?
/test/table/test_table.py should be the best place for it - and you can use the current tests there as inspiration

Comment on lines +253 to +264
# Modification pour issue #1460 : On autorise le dépassement de page
# if (
# page_break
# and self._fpdf.y + pagebreak_height > self._fpdf.page_break_trigger
# ):
# # Restoring original position on page:
# self._fpdf.x = prev_x
# self._fpdf.y = prev_y
# self._fpdf.l_margin = prev_l_margin
# raise ValueError(
# f"The row with index {i} is too high and cannot be rendered on a single page"
# )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please delete the commented code block
We don't keep dead code in the repository - git history is good enough if we ever need to recover old code


# Continue to the next cell
continue
# --- END MODIFICATION ---
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove # --- START MODIFICATION / END MODIFICATION comments
Reserve comments for pieces of code you believe are complicated enough to warrant the additional information

@Lucas-C
Copy link
Member

Lucas-C commented Dec 22, 2025

Hi @Neyhlo

Without any answer from you, we will soon close this PR.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants