forked from reingart/pyfpdf
-
Couldn't load subscription status.
- Fork 317
Open
Labels
Description
Error details
In the below example, a series of 10 tables of two rows each is created using the unbreakable context manager based on the logic described here.
Instead of the page break triggering before the unbreakable context manager as described, the table that triggers the page break (which should have cells labelled Test 31 to Test 37) does not get displayed.
This is perhaps down to me not fully understanding the syntax around using unbreakable, but I don't think so! I'm open to correction, of course!
Minimal code
from itertools import batched
import fpdf
PDF = fpdf.FPDF()
PDF.set_font("Helvetica", size=10)
PDF.add_page()
# create some test data
CELL_COUNT = 50
labels = [f"Test {i+1}" for i in range(CELL_COUNT)]
# group the data in batches
col_count = 5
label_groups = list(batched(labels, col_count))
# generate a separate table for each group with the labels as table headers
for group in label_groups:
with PDF.unbreakable() as doc:
doc.ln()
with doc.table(
text_align="CENTER",
gutter_width=10,
) as table:
table.row(group)
row = table.row()
for item in group:
row.cell("DON'T PANIC - CELL LEFT INTENTIONALLY BLANK")
PDF.output("unbreakable_bug_test.pdf")Environment
Please provide the following information:
- Operating System: Windows 11
- Python version: 3.12.1
fpdf2version used: 2.7.9
jcavalca