wx_4.0.0a1 : demo->PDFViewer

Hi,

I had to replace .FromBufferRGBA with .FromBuffer in line 518 of

wx/lib/pdfviewer/viewer.py to get the demo working . It seems that

the PyMuPDF (PyMuPDF-1.10.0) object fitz.fitz.Pixmap does not

provide the alpha channel information. The len of pix.samples was

pix.widthpix.height3 . pix.alpha was 0.

Environment: ubuntu 17.04, python_3.6.1, mupdf 1.10a .

regards

Uwe

The version of wx/lib/pdfviewer/viewer.py in wxPython-4.0.0a1 was tested using PyMuPDF 1.92 and Python 3.4 on both Windows 10 and OS X in July 2016. The Windows machine has since been rebuilt with the March 2017 release of Windows 10 and has Python 3.6. I have just installed the pre-built Windows version of PyMuPDF 1.10.0.0 there from https://github.com/JorjMcKie/PyMuPDF-optional-material which has the associated comment “Defaulting alpha=True b/o backward compatibility” and the pdf viewer works fine with it. On the line you refer to, in the call to wx.Bitmap.FromBufferRGBA(pix.width, pix.height, pix.samples) the len of pix.samples is width * height * 4.

Maybe your version of PyMuPDF is not compatible with the MuPDF you have built. The dialogue going on at https://github.com/rk700/PyMuPDF/issues/90 might be relevant.

Regards
David Hughes

I then think the problem is the following change ( https://mupdf.com/news.html ) :

MuPDF 1.10-rc1 (2016-11-09) : Alpha channel is now optional in pixmaps.

···

Am Dienstag, 25. April 2017 14:05:30 UTC+2 schrieb David Hughes:

The version of wx/lib/pdfviewer/viewer.py in wxPython-4.0.0a1 was tested using PyMuPDF 1.92 and Python 3.4 on both Windows 10 and OS X in July 2016. The Windows machine has since been rebuilt with the March 2017 release of Windows 10 and has Python 3.6. I have just installed the pre-built Windows version of PyMuPDF 1.10.0.0 there from https://github.com/JorjMcKie/PyMuPDF-optional-material which has the associated comment “Defaulting alpha=True b/o backward compatibility” and the pdf viewer works fine with it. On the line you refer to, in the call to wx.Bitmap.FromBufferRGBA(pix.width, pix.height, pix.samples) the len of pix.samples is width * height * 4.

Maybe your version of PyMuPDF is not compatible with the MuPDF you have built. The dialogue going on at https://github.com/rk700/PyMuPDF/issues/90 might be relevant.

Regards
David Hughes

I don’t know where your version of pyMuPDF was obtained from or when it was created, but the version available now from GitHub - pymupdf/PyMuPDF: PyMuPDF is a high performance Python library for data extraction, analysis, conversion & manipulation of PDF (and other) documents. was modified on April 3 and the default keyword argument in the definition of getPixmap in fitz/utils.py was changed from alpha=False to alpha=True. So if you download and install this version, wx.lib.pdfviewer should work without requiring any changes.

Regards, David

···

On Tuesday, April 25, 2017 at 2:35:11 PM UTC+1, uwe wrote:

I then think the problem is the following change ( https://mupdf.com/news.html ) :

MuPDF 1.10-rc1 (2016-11-09) : Alpha channel is now optional in pixmaps.