Python Tkinter GUI Script to Convert PDF Document to Images (PNG+JPEG) Using pdf2image Library Full Project For Beginners

Python Tkinter GUI Script to Convert PDF Document to Images (PNG+JPEG) Using pdf2image Library Full Project For Beginners

 

Welcome folks today in this post we will be converting pdf documents to images using pdf2image library in tkinter gui app. All the source code of the application will be shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to install the following libraries into your python project by using the pip command

 

pip install tkinter

 

pip install pdf2image

 

After installing these libraries just make an app.py file and copy paste the following code

 

app.py

 

from pdf2image import convert_from_path
from tkinter import *
from tkinter import messagebox


def pdf2img():
    try:
        images = convert_from_path(str(e1.get()))
        for img in images:
            img.save('output.jpg', 'JPEG')

    except :
        Result = "NO pdf found"
        messagebox.showinfo("Result", Result)

    else:
        Result = "success"
        messagebox.showinfo("Result", Result)



master = Tk()
Label(master, text="File Location").grid(row=0, sticky=W) 

e1 = Entry(master)
e1.grid(row=0, column=1)

b = Button(master, text="Convert", command=pdf2img)
b.grid(row=0, column=2,columnspan=2, rowspan=2,padx=5, pady=5)

mainloop()

 

READ  Python 3 FFMPEG Script to Crop or Cut Video Based on TimeStamp and Generate Short Video Preview Full Project For Beginners

 

If you execute this python script by typing the below command in the command prompt

 

python app.py

 

 

 

 

 

Leave a Reply