Traceback (most recent call last):
File "C:\Users\Momento\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\Momento\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Momento\AppData\Local\Programs\Python\Python38\lib\site-packages\tkPDFViewer\tkPDFViewer.py", line 46, in add_img
pix = page.getPixmap()
AttributeError: 'Page' object has no attribute 'getPixmap'```
I had the same problem few days ago and i found the solution. I edit the Funktion add_img because there was a mistake with the ussage of the fitz Libary Here is my code:
def add_img():
precentage_dicide = 0
open_pdf = fitz.open(pdf_location)
for page in open_pdf:
pix = page.get_pixmap()
pix1 = fitz.Pixmap(pix,0) if pix.alpha else pix
img = pix1.tobytes("ppm")
timg = PhotoImage(data = img)
self.img_object_li.append(timg)
if bar==True and load=="after":
precentage_dicide = precentage_dicide + 1
percentage_view = (float(precentage_dicide)/float(len(open_pdf))*float(100))
loading['value'] = percentage_view
percentage_load.set(f"Please wait!, your pdf is loading {int(math.floor(percentage_view))}%")
if bar==True and load=="after":
loading.pack_forget()
self.display_msg.pack_forget()
for i in self.img_object_li:
self.text.image_create(END,image=i)
self.text.insert(END,"\n\n")
self.text.configure(state="disabled")
There is nothing wrong with your Code, the Libary has 2 Issues. Swap the Funktion add_img in the file C:\Users\Momento\AppData\Local\Programs\Python\Python38\lib\site-packages\tkPDFViewer\tkPDFViewer.py with the Code in my previous post
I am having de same issue using tkPDFViewer library. here the error im getting AppData\Local\Programs\Python\Python310\lib\site-packages\tkPDFViewer\tkPDFViewer.py", line 46, in add_img pix = page.getPixmap() AttributeError: 'Page' object has no attribute 'getPixmap'. Did you mean: 'get_pixmap'? well, then if i change getPixmap to get_pixmap I get the following error:
`AppData\Local\Programs\Python\Python310\lib\site
packages\tkPDFViewer\tkPDFViewer.py", line 48, in
add_imgimg = pix1.getImageData("ppm")
AttributeError: 'Pixmap' object has no attribute 'getImageData'`
A lot of people need some help from tkPDFViewer’s owner. but what I want is, pip community have to delete this tkPDFViewer library, because it has no a preview version, it is the only version the owner release, then if the very first release doesn’t work, it means the owner have not tested his code before pushing it into production. the owner should have specified versions for any change made in the code rather than pushing the code in differing method to bypass pip version controller. and that change of GETPIXMAP should be considered as mayor change of version. here I’m using the library:
`# 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.
root.geometry("550x750")
# creating object of ShowPdf from tkPDFViewer.
v1 = pdf.ShowPdf()
# Adding pdf location and width and height.
v2 = v1.pdf_view(root,pdf_location = r"simplepdf.pdf",width =
50,height = 100)
# Placing Pdf in my gui.
v2.pack()
root.mainloop()`