rednaks
rednaks

Reputation: 2042

display pdf with python using pdfviewer

I'm trying to display a pdf using pdfviewer lib from wx but I can't find the module. I already have the wxPython installed is it deprecated ?

I'm following this tutorial :

http://wxpython.org/Phoenix/docs/html/lib.pdfviewer.html#module-lib.pdfviewer

And I'm getting : ImportError: No module named pdfviewer

Upvotes: 0

Views: 7347

Answers (3)

kk1
kk1

Reputation: 53

wx.lib.pdfviewer was added in version 2.9.1.1. link There is a PPA for wxpython 2.9.4.1 (for ubuntu 12.04), so if you happened to use ubuntu 12.04, you can try the PPA. link

sudo add-apt-repository ppa:delmic-soft/odemis
sudo apt-get update
sudo apt-get install python-wxgtk2.9

Then you can do

>>> import wx.lib.pdfviewer
>>>

However, not sure if it is fully compatible with 2.8.

Upvotes: 0

Mike Driscoll
Mike Driscoll

Reputation: 33071

The PDFViewer works for me, although it's a bit picky about what PDFs it will load. I wasn't able to get it to work with pyPDF2, but it loaded fine with the old pyPDF. I am running wxPython Phoenix 3.0.1 on Windows 7 with Python 2.7. On Windows, there also an ActiveX version of the PDF viewer that might be a bit better. You'll need to make sure you have comtypes installed though if you go that route.

Upvotes: 0

drmariod
drmariod

Reputation: 83

I am not allowed to write comments, so sorry for asking this question as my answer, but have you seen the comment on the website?

The viewer uses pyPDF2 or pyPdf, if neither of them are installed an import error exception will be thrown.

Upvotes: 1

Related Questions