David Hughes wrote:
Following recent discussions on this list, I have amended the pdf viewer
to search in turn for, and work with, the modules python-fitz/mupdf,
pypdf2 and pypdf. A patch to the current version of viewer.py is
attached, together with one for consequential changes to demo/pdfviewer.py.
These have kindly been tested by Werner so I submit them for acceptance
into wxPython Classic.
The following is a link to fitz.zip which contains the win32, Python 2.7
build of python-fitz (can be copied directly into site-packages) as the
setup.py and mupdf library names for Windows are not the same as those
provided in the python-fitz-master download.
LogMeIn - Remote Access and Desktop Control Software
Hi David,
I'm finally getting around to reviewing these patches and I have run into some exceptions while testing. Using the pyPdf package I'm seeing this:
Traceback (most recent call last):
File "/Users/robind/projects/wx/2.9/wxPython/demo/PDFViewer.py", line 49, in OnLoadButton
self.viewer.LoadFile(dlg.GetPath())
File "/Users/robind/projects/wx/2.9/wxPython/wx/lib/pdfviewer/viewer.py", line 221, in LoadFile
self.pdfdoc.DrawFile(self.frompage, self.topage)
File "/Users/robind/projects/wx/2.9/wxPython/wx/lib/pdfviewer/viewer.py", line 586, in DrawFile
pdf_fonts = self.FetchFonts(self.page)
File "/Users/robind/projects/wx/2.9/wxPython/wx/lib/pdfviewer/viewer.py", line 637, in FetchFonts
fonts = currentobject["/Resources"].getObject()['/Font']
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyPdf/generic.py", line 480, in __getitem__
return dict.__getitem__(self, key).getObject()
KeyError: '/Font'
and this:
Traceback (most recent call last):
File "/Users/robind/projects/wx/2.9/wxPython/demo/PDFViewer.py", line 49, in OnLoadButton
self.viewer.LoadFile(dlg.GetPath())
File "/Users/robind/projects/wx/2.9/wxPython/wx/lib/pdfviewer/viewer.py", line 221, in LoadFile
self.pdfdoc.DrawFile(self.frompage, self.topage)
File "/Users/robind/projects/wx/2.9/wxPython/wx/lib/pdfviewer/viewer.py", line 588, in DrawFile
self.page.extractOperators(), pdf_fonts)
File "/Users/robind/projects/wx/2.9/wxPython/wx/lib/pdfviewer/viewer.py", line 720, in ProcessOperators
drawlist.extend(self.InsertXObject(operand[0]))
File "/Users/robind/projects/wx/2.9/wxPython/wx/lib/pdfviewer/viewer.py", line 893, in InsertXObject
dlist.append(self.AddBitmap(stream._data, width, height, filters))
File "/Users/robind/projects/wx/2.9/wxPython/wx/lib/pdfviewer/viewer.py", line 919, in AddBitmap
bitmap = wx.BitmapFromBuffer(width, height, data)
File "/Users/robind/projects/wx/2.9/wxPython/wx/_gdi.py", line 938, in BitmapFromBuffer
return _gdi_._BitmapFromBuffer(width, height, dataBuffer)
TypeError: in method '_BitmapFromBuffer', expected argument 2 of type 'int'
I tried using int() at that line of code and apparently the parameter is an IndirectObject instead of something that is convertible to an int.
I got the same errors after upgrading to pyPdf2.
···
--
Robin Dunn
Software Craftsman