Emile GROS
Emile GROS

Reputation: 1

arranging images with FPDF loop

I have five images in a file and I'd like to put two per page... the first two on one page, then the next two on the second and the last one on a third page. in the end I want a loop, where each image is positioned one after the other, passing a page as soon as there's no more space for the next image... I think it should be easy but I can't do it.

page1 page2

I've copied the previous code, thank you very much.

png_count = 0
start_y = 50
img_ht = 115
for name in imagelist:
    if png_count%2 == 0:
        pdf.image(name, 20, start_y, 160, 100.4)
    else:
        start_y += img_ht
        pdf.image(name, 20, start_y, 160, 100.4)
    png_count += 1
    if png_count%3 == 0:
        pdf.add_page()

There are the first two figures on the first page, but then when I turn to the second page, the third figure goes to the bottom. I don't know why...

Thanks in advance for your help

arrange images automatically with FPDF

Upvotes: 0

Views: 60

Answers (0)

Related Questions