In this article, We are going to see how to add a PDF file Tkinter GUI, For that, we don’t have a direct widget to do this. For that, We need to have python version 2.7 or more. And you need to install the ‘tkPDFViewer‘ library. This library allows you to embed the PDF file in your Tkinter GUI.
To install this library you just have to type:
pip install tkPDFViewer
- Initialize tk and geometry of our GUI.
- Import tkPDFViewer.
- Make the object of Class ShowPdf() from tkPDFViewer.
- Using pdf_view method from ShowPdf() to place our pdf.
- Pack the pdf_view in GUI.
Arguments of method pdf_view:
|pdf_location = “location of your PDF”||To add your location of PDF.|
|width = 0||To set the width of PDF Frame.|
|height = 0||To set the height of the PDF Frame.|
|bar = True or False||To hide or unhidden the loading bar.|
|load = after or before||To decide that, when your pdf object is to convert.|
Below is the implementation:
We are using this pdf for demonstration:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.