Welcome folks today in this post we will be displaying
pdf file inside tkinter application using the
tkPDFViewer library. All the full source code of the application is shown below.
In order to get started you need to install the following library using the
pip command as shown below
pip install tkinter
pip install tkPDFViewer
After installing all these libraries now make an
app.py file and copy paste the following code
# Importing tkinter to make gui in python
from tkinter import*
# Importing tkPDFViewer to place pdf file in gui.
# In tkPDFViewer library there is
# an tkPDFViewer module. That I have imported as pdf
from tkPDFViewer import tkPDFViewer as pdf
# Initializing tk
root = Tk()
# Set the width and height of our root window.
# creating object of ShowPdf from tkPDFViewer.
v1 = pdf.ShowPdf()
# Adding pdf location and width and height.
v2 = v1.pdf_view(root,
pdf_location = r"##locationofpdfile##.pdf",
width = 50, height = 100)
# Placing Pdf in my gui.
Now in the above
python script just replace the path of the input
Now if you run this python script
app.py by typing the following command