Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python FPDF Layout #184

Open
Jamesaarr opened this issue Jul 29, 2021 · 1 comment
Open

Python FPDF Layout #184

Jamesaarr opened this issue Jul 29, 2021 · 1 comment

Comments

@Jamesaarr
Copy link

Jamesaarr commented Jul 29, 2021

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()
@Lucas-C
Copy link

Lucas-C commented Aug 23, 2021

PyFPDF is not maintained anymore, you may want to check PyFPDF/fpdf2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants