pdfViewer bugfix

Apologies for posting this here. Just a beginner, don’t know how to use github. This might be useful though:

Demo Code posted here works on python 2.7 but not on 3.8- onwards
https://pythonhosted.org/wxPython/wx.lib.pdfviewer.html

fitz.version → (‘1.20.0’, ‘1.20.1’, ‘20220627000001’)
wx.version() – > ‘4.1.1 gtk3 (phoenix) wxWidgets 3.1.5’

Bug and fix are found in ~/.local/lib/python3.10/site-packages/wx/lib/pdfviewer/viewer.py
on
pdfViewer.Render (line 410) and
mupdfProcessor.init() line 499 and 500

  1. AttributeError: ‘Document’ object has no attribute ‘pageCount’. Did you mean: ‘page_count’?
    The error was found in viewer.py lines 499-500:
    self.numpages = self.pdfdoc.pageCount
    page = self.pdfdoc.loadPage(0)
    pageCount was renamed to page_count, and loadPage is now load_page.
    This fixed it:
    if hasattr(self.pdfdoc,‘pageCount’):
    self.numpages = self.pdfdoc.pageCount
    else:
    self.numpages=self.pdfdoc.page_count

     if hasattr(self.pdfdoc,'loadPage'):
         page = self.pdfdoc.loadPage(0)
     else:
         page=self.pdfdoc.load_page(0)
    
  2. LIne 410: self.pagebuffer = wx.Bitmap(self.pagebufferwidth, self.pagebufferheight)
    changed to : self.pagebuffer = wx.Bitmap(int(self.pagebufferwidth), int(self.pagebufferheight))