pyfpdf
pyfpdf copied to clipboard
Python FPDF Layout
Hello,
I'm trying to get my code to generate 'labels' four to a page. However I am currently only able to get them to place two (Both down the left side of the page).
To awkwardly try and explain this further:
|1|2| |3|4|
is what I want but: |1 | |2 |
Is what I get.
Please see my code below
style_colour = int(0)
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size = 12)
while a > -1:
if y == len(total_labels):
break
if a < total_labels[y]:
print("Printing")
pdf.cell(100, 10, txt = send_line1,
ln = 1, align = '')
pdf.cell(100, 10, txt = send_line2,
ln = 2, align = '')
pdf.cell(100, 10, txt = send_city + ", " + send_postcode,
ln = 3, align = '')
pdf.cell(100, 10, txt = " ",
ln = 4, align = '')
pdf.cell(100, 10, txt = " ",
ln = 5, align = '')
pdf.cell(100, 10, txt = "PO#: " + order,
ln = 6, align = '')
pdf.cell(100, 10, txt = " ",
ln = 7, align = '')
pdf.cell(100, 10, txt = str(label_list[style_colour]) + " " + str(label_list[style_colour + 1]),
ln = 8, align = '')
pdf.cell(100, 10, txt = " ",
ln = 9, align = '')
pdf.cell(100, 10, txt = rec_line1,
ln = 10, align = '')
pdf.cell(100, 10, txt = rec_line2,
ln = 11, align = '')
pdf.cell(100, 10, txt = rec_city + ", " + rec_postcode,
ln = 12, align = '')
pdf.cell(100,10, txt = " ",
ln = 13, align = '')
a = a + 1
if a == total_labels[y]:
print("Printing Next")
y = y + 1
a = int(0)
style_colour = style_colour + 4
print("Printing Complete....")
pdf.output(order + ".pdf")
main()
PyFPDF is not maintained anymore, you may want to check PyFPDF/fpdf2