Python Script to convert pdf to image one command line

script to convert pdf to image using Python 3 simple command line you can use it by just copy and paste in your console and run it and see the results


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()