Skip to content

Fix: do not insert bottom padding in cells produced by multi_cell() when a page break occurs in them #1398

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
### Fixed
* [`FPDF.write_html()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.write_html): Fixed rendering of content following `<a>` tags; now correctly resets emphasis style post `</a>` tag: hyperlink styling contained within the tag authority. - [Issue #1311](https://github.com/py-pdf/fpdf2/issues/1311)
* [FPDF.footer()](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.footer) does not "leak" its text style to the [table of contents](https://py-pdf.github.io/fpdf2/DocumentOutlineAndTableOfContents.html#table-of-contents) anymore
* do not insert bottom padding in cells produced by [`FPDF.multi_cell()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.multi_cell) when a page break occurs in them - [issue #1395](https://github.com/py-pdf/fpdf2/issues/1395)

## [2.8.2] - 2024-12-16
### Added
Expand Down
2 changes: 1 addition & 1 deletion fpdf/fpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4146,7 +4146,7 @@ def multi_cell(
page_break_triggered = False

for text_line_index, text_line in enumerate(text_lines):
if self._perform_page_break_if_need_be(h + padding.bottom):
if self._perform_page_break_if_need_be(h):
page_break_triggered = True
self.y += padding.top

Expand Down
Binary file not shown.
10 changes: 10 additions & 0 deletions test/text/test_multi_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,16 @@ def test_multi_cell_with_padding_check_input():
pdf.multi_cell(0, 5, LONG_TEXT, border=1, padding=(5, 5, 5, 5, 5, 5))


def test_multi_cell_with_padding_and_page_break(tmp_path): # issue #1395
pdf = FPDF()
pdf.add_page()
pdf.set_font("Helvetica")
pdf.multi_cell(
w=0, text="Hello, this is a sample PDF!" * 300, padding=[0, 0, 50, 0]
)
assert_pdf_equal(pdf, HERE / "multi_cell_with_padding_and_page_break.pdf", tmp_path)


def test_multi_cell_return_value(tmp_path):
pdf = FPDF()
pdf.add_page()
Expand Down