python用fpdf模块将多张图片合并为PDF,亲测可用

"""将多张图片合并为PDF,亲测可用"""
import os
from fpdf import FPDF

path = "e:\\Python\教程\\哪吒系列\\Python_L3_进阶篇"

pdf = FPDF()
imagelist  = []
for image in os.listdir(path):
        if ".png" in image:
            filename = path + os.sep + image
            imagelist.append(filename)
            
for image in imagelist:
    pdf.add_page()
    pdf.image(image)
pdf.output("e:/哪咤学编程之进阶篇.pdf", "F")

 
print(help(pdf.image))