Aug-09-2021, 10:16 AM
Hello all, me again,
Basically my entire program is below and I'm looking for a way to change the layout of the generated pdf (Either using FPDF or reportlabs as was suggested to me previously) but I'm struggling. I need 4 labels to a page (One top left, one top right, one bottom left and one bottom right).
Basically my entire program is below and I'm looking for a way to change the layout of the generated pdf (Either using FPDF or reportlabs as was suggested to me previously) but I'm struggling. I need 4 labels to a page (One top left, one top right, one bottom left and one bottom right).
from fpdf import FPDF def main(): print("***********************************************") print(" Welcome to the Label Maker Program V2.2 ") print("***********************************************") label_list = [] total_labels = [] print ("Please input the sending address following the prompts below.") print ("Line 1: ") send_line1 = input() print ("Line 2: ") send_line2 = input() print ("City/Town: ") send_city = input() print ("Postcode: ") send_postcode = input() print (send_line1 + ", " + send_line2 + ", " + send_city + ", " + send_postcode) print (" ") print ("Is this correct? Y/N: ") a = input() if a == ("N") or a ==("n"): main() if a == ("No") or a == ("no"): main() print ("Please input the recieving address following the prompts below.") print ("Line 1: ") rec_line1 = input() print ("Line 2: ") rec_line2 = input() print ("City/Town: ") rec_city = input() print ("Postcode: ") rec_postcode = input() print (rec_line1 + ", " + rec_line2 + ", " + rec_city + ", " + rec_postcode) print (" ") print ("Is this correct? Y/N: ") b = input () if b == ("N") or b == ("n"): main() if b == ("No") or b == ("no"): main() print ("Please input the order number for this order: ") order = input() print ("Please input the number of distinct items on the PO: ") i = int(input()) a = int(0) z = int(0) y = int(2) while a != i: print ("Please input the style number of this item: ") label_list.append(input()) print("Please input the colour of this item: ") label_list.append(input()) print("Please input the number of labels required for each unit of this item: ") label_list.append(int(input())) print("Please input the quantity of this item: ") label_list.append(int(input())) total_labels.append(label_list[y] * label_list[y + 1]) print (label_list) print (total_labels) y = y + 4 a = a + 1 a = int(0) y = int(0) 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()
while dad_has_cigs == True: happiness = True if dad_has_cigs == False: print("Dad come home!") happiness = not happiness break