This project aims to convert JPG to PDF format using img2pdf or Filedialog module. Used Tkinter to create a GUI application, which is the most common and easiest way to create GUI applications.
Tkinter is the inbuilt library of Python that allows you to create a GUI Graphical User Interface, a relatively easy and most commonly used application.
let us create a Tkinter application
1. Import the Tkinter module
2. Create the GUI application main window
3. Add widgets to the main window
4. Apply the event Trigger on the widgets.
img2pdf module is a lossless conversion of images to pdf format. As PDF is a portable document format, which is easy to read, occupies less space, and is not easily editable this ensures security. It includes another module Pillow.
install the imgtopdf module using the command below.
pip install img2pdf
Python Tkinter provides us a way to open a dialog for opening a file, reading a file, saving a file, etc. All these functionalities are part of filedialog module in python. Certain other modules contain the filedialog such as askopenfilename, asksaveasfilename, askdirectory, etc.
We will import filedialog to open a dialog box that asks the user's to select and save files in the directory.
To create the application we mainly use the below functions.
askopenfilenames() is the function that displays an open file dialog that allows users to select files.
asksaveasfilename() is the function, which is used to save a user’s file (extension can be set explicitly or you can set default extensions also).
from tkinter import messagebox
Pillow is a module used for image processing in Python. Using the pillow module we can load the images, create the images, etc.
Use this command to install PIL:
pip install pillow
Submitted by Ramya Sri Balla (ballaramyasri4444)
Download packets of source code on Coders Packet