I am wondering if there is an easy way to combine multiple png images into a single pdf in python. I want each image to be a single page in the pdf. Is pypdf the best librar
I've got the same problem.
So I've created python function to unite multiple pictures in one pdf. Code is available at my github page on https://github.com/wizard1989/Unite-multiple-pictures-into-pdf. It uses "reportlab".
Code is based on answers from the following links:
Create PDF from a list of images
Combining multiple pngs in a single pdf in python
png images to one pdf in python
How can I convert all JPG files in a folder to PDFs and combine them?
https://www.blog.pythonlibrary.org/2012/01/07/reportlab-converting-hundreds-of-images-into-pdfs/
Here is example of how to unite images into pdf.
We have folder "D:\pictures" with pictures of types png and jpg. We want to create file pdf_with_pictures.pdf out of them and save it in the same folder.
outputPdfName = "pdf_with_pictures"
pathToSavePdfTo = "D:\\pictures"
pathToPictures = "D:\\pictures"
splitType = "none"
numberOfEntitiesInOnePdf = 1
listWithImagesExtensions = ["png", "jpg"]
picturesAreInRootFolder = True
nameOfPart = "volume"
unite_pictures_into_pdf(outputPdfName, pathToSavePdfTo, pathToPictures, splitType, numberOfEntitiesInOnePdf, listWithImagesExtensions, picturesAreInRootFolder, nameOfPart)