Easily convert images to PDF with Python

Simone Rigoni
2 min readOct 25, 2020

Quick and easy python script to convert images to PDF

convert images to PDF

Many times you have to create a PDF starting from some images. The idea is to run an .exe file from any folder on the PC that will take as input some images filename and it will create a PDF file. The order of the images in the PDF will be the same in which the images are passed to the .exe. By default the output filename will be merge.pdf

Let’s have a look at the code:

Python script

Basically the steps are:
1 taking the images filename as input
2 open the images with PIL
3 convert the images in RGB
4 save the PDF appending all the images

Using Pyinstaller we can create an executable file starting from our python script

Finally we just have to place the executable file in a folder from which we can run it from any folder in our PC

Outro

I hope the story was interesting and thank you for taking the time to read it. The code for this project can be found in this github repository and on my Blogspot you can find the same post in Italian. Let me know if you have any question and if you like the content that I create feel free to buy me a coffee.

--

--