fpdf2
fpdf2 copied to clipboard
Table layout will break if the content of a cell requires more than one page
When the content of one cell within a table is too long, the layout will break. table.pdf
Minimal code
from fpdf import FPDF
WEIRD_LONG_TEXT = "Just generate a very long text with any lorem ipsum generator, make sure it is long enough to require more than one page"
TABLE_DATA = (
("First name", "Last name", "Age", "City"),
("Jules", "Smith", "34", "San Juan"),
("Mary", "Ramos", "45", WEIRD_LONG_TEXT),
("Carlson", "Banks", "19", "Los Angeles"),
)
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table() as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
pdf.output('table.pdf')
Environment Please provide the following information:
- Operating System: Fedora 39
- Python version: 3.11.8
-
fpdf2
version used: 2.7.8