Created
October 20, 2019 09:20
-
-
Save sagorbrur/f7bdf3fea732b14977745057467eca99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dependecies | |
# python 3 | |
# pip install fpdf | |
# to run: python fpdf.py | |
from fpdf import FPDF | |
from PIL import Image | |
import os | |
listPages = os.listdir("images") | |
def makePdf(pdfFileName, listPages, dir = ''): | |
if (dir): | |
dir += "/" | |
cover = Image.open(dir + str(listPages[0])) | |
width, height = cover.size | |
pdf = FPDF(unit = "pt", format = [width, height]) | |
for page in listPages: | |
pdf.add_page() | |
pdf.image(dir + str(page), 0, 0) | |
pdf.output(pdfFileName + ".pdf", "F") | |
makePdf('output.pdf', listPages, 'images') | |
# ref: https://stackoverflow.com/questions/27327513/create-pdf-from-a-list-of-images |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment