Skip to content

Instantly share code, notes, and snippets.

@rostegg
Created June 15, 2019 20:02
Show Gist options
  • Select an option

  • Save rostegg/ce26f79e65d41c720c2b96f74f2bdec7 to your computer and use it in GitHub Desktop.

Select an option

Save rostegg/ce26f79e65d41c720c2b96f74f2bdec7 to your computer and use it in GitHub Desktop.
Build PDF from images
from fpdf import FPDF
from PIL import Image
PATH = 'images/'
files = [PATH + f for f in listdir(PATH) if isfile(join(PATH, f))]
# format - widt&heigh of images
pdf = FPDF(unit="pt", format=[1600, 2400])
for f in files:
pdf.add_page()
pdf.image(f, 0, 0)
pdf.output("output.pdf", "F")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment