pdf.unbreakable() seems a bit broken #557
Replies: 2 comments 7 replies
-
That's what the search function at the top of the page is there for. If you file a bug as an issue, you will be presented with a template. Please make sure to provide all the information it asks for. |
Beta Was this translation helpful? Give feedback.
-
ok. after some testing and debugging I found something. from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
line_height = pdf.font_size * 2
col_width = pdf.epw / 4
data = (
("First name", "Last name", "Age", "City"),
("Jules", "Smith", "34", "San Juan"),
("Mary", "Ramos", "45", "Orlando"),
("Carlson", "Banks", "19", "Los Angeles"),
("Lucas", "Cimon", "31", "Saint-Mahturin-sur-Loire"),
)
pdf.set_fill_color(255, 0, 0)
for i in range(5):
with pdf.unbreakable() as doc:
for row in data:
with doc.local_context(fill_opacity=0.3):
doc.cell(col_width, line_height, f"doc.get_y(): {int(doc.get_y())}", border=1, fill=True)
for datum in row:
doc.cell(col_width, line_height, f"{datum} ({i})", border=1)
doc.ln(line_height)
pdf.ln(line_height * 2)
pdf.output("unbreakable_tables.pdf")
|
Beta Was this translation helpful? Give feedback.
-
Hey,
before I file an issue I wonder if anyone else mentioned it.
if a
with pdf_file.unbreakable() as pdf:
causes a page break, the footer of the previous page and the header of the new page won't be added.
Also
with pdf.local_context(fill_opacity=0.3):
will not work on the newly created page.
Any help is appreciated.
Beta Was this translation helpful? Give feedback.
All reactions