Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

create pdf from images python

from PIL import Image
from natsort import natsorted
file_names = os.listdir(file_path)
file_names = natsorted(file_names) #Python doesn't have a built-in way to have natural sorting so I needed to import a specific library to do it

pdfimages = [Image.open(f"{file_path}/{f}") for f in file_names]
pdf_path = file_path + 'pdfname' + '.pdf'

pdfimages[0].save(pdf_path, "PDF" , resolution=100.0, save_all=True, append_images=pdfimages[1:])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #create #pdf #images #python
ADD COMMENT
Topic
Name
1+4 =