![]() So in this way you can create a simple PDF viewer, I hope this article might be fruitful to you, thank you ‘Keep Learning Keep Coding’. Because we learned how to read and write, we understand document layouts, from which letters form words, words form sentences, sentences form paragraphs and so. The conclusion that I could arrive at is that every image needs the separate permanent storage until the PDF is rendered.īy looking at this task code it seems to be simple, but it took me around 8 hours to arrive at this solution because in this I had tried every possible solution I could have found and lastly I had found it, this was really a challenging and interesting task. Here you must be thinking why I have used two for loops one adding images to list and the second one for adding images to the text widget, I had actually used one loop but then it was only showing the last page in the PDF, this might be happening, because I was using a single variable to hold the image and store into text widget. # Adding all the images to the text widget # Here the PDF is converted to list of images # Setting the scrollbar to the right side Pdf = Text(pdf_frame,yscrollcommand=scrol_y.set,bg="grey") # Adding text widget for inserting images Scrol_y = Scrollbar(pdf_frame,orient=VERTICAL) ![]() Pdf_frame = Frame(root).pack(fill=BOTH,expand=1) Source Code: Create a PDF viewer GUI in Python # Importing required modules Installation: $ sudo apt-get install python3-tkĪfter installing the above modules and required dependencies you can get into actual code. PIL/Pillow – It is a free library in python which supports opening, manipulating different image file formats.īefore getting into the code you need to install the above-mentioned libraries.For example, in our case, it is 20 (see first line of output). print (pdfReader.numPages) numPages property gives the number of pages in the pdf file. pdf2img – It is an easy to use command line module that provides users with a batch conversion of PDF into Images. Here, we create an object of PdfFileReader class of PyPDF2 module and pass the pdf file object & get a pdf reader object.Tkinter – It is the most preferred GUI toolkit available in python, which posses the faster and easiest way of producing GUI software.In this tutorial we will learn how to create PDF viewer using python, this is a GUI toolkit which uses python Tkinter module, Pdf2img module, and Python Imaging Library ( PIL).Īs the increasing popularity and compatibility of PDFs in almost each and every document format, whether it is Invoices, Reports or other official documents, we need an onboard PDF viewer or renderer to seek out the information repeatedly.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |