Coders Packet

Image to PDF Converter using Python

By Vishaka Iyengar

An image to PDF converter has multiple applications in day-to-day life as well as office applications such as making a file of inventory papers.

An image to PDF converter has innumerable applications in daily life such as converting notes, assignments, documents and many more pictures into a PDF format for easier access and handling. 

To run this Python code, you must install the Pillow module like so:

Once installed, follow the code above to convert the chosen image to a pdf format. 

This code will require you to paste in the complete path of the image so as to access it, and the complete path where the newly formed PDF must be stored. The process to access the file path in windows 10 is as follows:

File Explorer --> View --> Options --> Change folder and search options --> View  --> Add a checck mark for Display the full path in Title Bar --> Apply --> Okay.

The file path will be visible in the title bar. 

The code is explained with comments within it.

# Image to PDF converter

from PIL import Image

# Enter the path where the image is stored along with the name of the image that must be converted.
image1 ='C:\Users\Admin\Pictures\Screenshots\SS1.png') #Enter your file path.
pic1 = image1.convert('RGB')
# Enter the path where the pdf must be stored along with the new name of the pdf.'C:\Users\Admin\Pictures\Screenshots\SS1.pdf') #Enter your file path.


Download Complete Code


No comments yet