problem with pdfviewer

I am trying to use pdfViewer and am having an issue. Here is my traceback:

Traceback (most recent call last):
File “pdfviwer_test.py”, line 32, in
pdfV.viewer.LoadFile(’…/bd_xml_OL2.pdf’)

File “/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wx-2.9.4-osx_cocoa/wx/lib/pdfviewer/viewer.py”, line 169, in LoadFile
self.CalculateDimensions(True) # to get initial visible page range

File “/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wx-2.9.4-osx_cocoa/wx/lib/pdfviewer/viewer.py”, line 281, in CalculateDimensions
self.frompage = min(self.y0/self.Ypagepixels, self.numpages-1)

ZeroDivisionError: integer division or modulo by zero

My python script (which is really just taken from here http://wxpython.org/Phoenix/docs/html/lib.pdfviewer.html) and the pdf file are attached. The pdf is one page and generated by tikz with latex preview mode (so it is actually only a portion of a page).

From looking at the traceback, I assume self.Ypagepixel is zero. I don’t know how that happened or how to fix it.

Thanks,

Ryan

pdfviwer_test.py (1.17 KB)

bd_xml_OL2.pdf (16.8 KB)

Hi Ryan,

···

On 27/09/2013 22:00, Ryan Krauss wrote:

I am trying to use pdfViewer and am having an issue. Here is my traceback:

Traceback (most recent call last):
  File "pdfviwer_test.py", line 32, in <module>
    pdfV.viewer.LoadFile('../bd_xml_OL2.pdf')
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wx-2.9.4-osx_cocoa/wx/lib/pdfviewer/viewer.py", line 169, in LoadFile
    self.CalculateDimensions(True) # to get initial visible page range
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wx-2.9.4-osx_cocoa/wx/lib/pdfviewer/viewer.py", line 281, in CalculateDimensions
    self.frompage = min(self.y0/self.Ypagepixels, self.numpages-1)
ZeroDivisionError: integer division or modulo by zero

My python script (which is really just taken from here http://wxpython.org/Phoenix/docs/html/lib.pdfviewer.html) and the pdf file are attached. The pdf is one page and generated by tikz with latex preview mode (so it is actually only a portion of a page).

From looking at the traceback, I assume self.Ypagepixel is zero. I don't know how that happened or how to fix it.

I am pretty sure this fixed in the latest version of pdfviewer. Best would be to get it from SVN as David did a couple of fixes after 2.9.5 came out.

Werner

Sorry for the late reply, I have been pretty involved in some other stuff for the last few days. Werner is right, you can get the latest version from SVN, or you can upgrade to wxPython 2.9.5.0 which also contains it and with which your sample PDF file works OK. The post 2.9.5 patch has been submitted but hasn’t been committed yet and it relates to a different, image sizing problem. See

https://groups.google.com/forum/?fromgroups#!topic/wxpython-users/Pl239rSsW6U

David Hughes

···

On Saturday, September 28, 2013 8:34:14 AM UTC+1, werner wrote:

Hi Ryan,

On 27/09/2013 22:00, Ryan Krauss wrote:

I am trying to use pdfViewer and am having an issue. Here is my traceback:

I am pretty sure this fixed in the latest version of pdfviewer. Best
would be to get it from SVN as David did a couple of fixes after 2.9.5
came out.

Werner