diff --git a/CHANGELOG.md b/CHANGELOG.md index 69f40564d..8d4f5533a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 `` tags; now correctly resets emphasis style post `` 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 diff --git a/fpdf/fpdf.py b/fpdf/fpdf.py index 5e9df0e65..c91924006 100644 --- a/fpdf/fpdf.py +++ b/fpdf/fpdf.py @@ -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 diff --git a/test/text/multi_cell_with_padding_and_page_break.pdf b/test/text/multi_cell_with_padding_and_page_break.pdf new file mode 100644 index 000000000..4f31a87b2 Binary files /dev/null and b/test/text/multi_cell_with_padding_and_page_break.pdf differ diff --git a/test/text/test_multi_cell.py b/test/text/test_multi_cell.py index 0f9348280..8f5612570 100644 --- a/test/text/test_multi_cell.py +++ b/test/text/test_multi_cell.py @@ -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()