Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table heading orphaned on previous page when first row is too long to fit #1391

Open
jasonfevangsafe opened this issue Mar 11, 2025 · 3 comments

Comments

@jasonfevangsafe
Copy link

When the first row of a table is too long to fit on the page, it moves to the next page and orphans the table heading on the previous page. Imo the table heading should not be displayed alone on the initial page. See the unit test pdf for a visual example.

Minimal code
This behaviour is codified in a unit test, test_table_with_page_break_over_image, copied below here.

from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
pdf.y = 220
with pdf.table() as table:
    for i, data_row in enumerate(TABLE_DATA[:2]):
        row = table.row()
        for j, datum in enumerate(data_row):
            if j == 2 and i > 0:
                row.cell(img=datum, img_fill_width=True)
            else:
                row.cell(datum)

Environment

  • Operating System: Windows
  • Python version: 3.12.2
    • fpdf2 version used: 2.8.2
@Lucas-C
Copy link
Member

Lucas-C commented Mar 11, 2025

Hi @jasonfevangsafe

Thank you for the excellent bug report 👍

I was able to reproduce the problem thanks to your code snippet.

Would you like to figure a solution and submit a Pull Request? 🙂

@Lucas-C
Copy link
Member

Lucas-C commented Mar 11, 2025

@allcontributors please add @jasonfevangsafe for bug

Copy link

@Lucas-C

I've put up a pull request to add @jasonfevangsafe! 🎉

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

No branches or pull requests

2 participants