Reputation: 53
I am fetching images and want to save images into single pdf file.
Below is the code which is creating multiple pdf for multiple images but I want all images should saved into single pdf :
in = Image.open(r". Output\demod.png" % i)
im = im.convert('RGB')
im = im.crop((left, top, right, bottom))
print(im)
imagelist = [im] print(imagelist)
pdf_path = im.save(r". \pdf\my_images%d.pdf" % i, save_all=True, append_images=imagelist)
in.close()
print("successfully made pdf file")
Could you please help me to resolve this?
Upvotes: 1
Views: 331
Reputation: 87
Try this:
pdf = FPDF()
for img in [Image.open(r".\Output\demod.png" * i)]:
im = img.convert('RGB')
cropped img = im.crop((left, top, right, bottom))
cropped_img.save(r".\Output\cropped%d.png" % i)
pdf.add page ()
pdf.image (r".\Output\cropped%d.png" & i, randint(1,20),randint(1, 20))
pdf.output('finalpdf.pdf', 'f')
Upvotes: 1