Output not doing anything when using PyFPDF

104 Views Asked by At

I'm trying to put all the images in a directory into a single PDF. I'm writing in python 3 and using PyFPDF. This is my code:

import os
from fpdf import FPDF
pdf = FPDF()
list = os.listdir(r'C:\this\is\my\destination\library')
count = 1
for name in list:
    path = r'C:\this\is\my\destination\library' + "\\" + name
    pdf.add_page()
    pdf.image(path, x=None, y=None)
    print(count)
    count+=1
print("done looping")
pdf.output('finaldocument.pdf', 'F')
print("done")

When I run this in my command window, it counts all the way up until the amount of images in the folder, then prints "done looping" and just sort of stops? It doesn't terminate, it just does nothing until I close the cmd window manually.

I've tried putting a D (and an S, and an I) instead of an F in the output args to explore all the options in the documentation, but nothing is taking. Anyone know what's wrong here?

0

There are 0 best solutions below