0

I have a python application using PySide, Qt and python. In my application I would like to open and display a pdf document, but have the viewer within the application and not using the default viewer on the operating system.

I have not as of yet been able to find a widget which is capable of doing this or some example code. I have never used these tools before and this is my first Qt & PySide application so I am sure there is a widget which is capable of this but that I am just not aware of it.

I found this post and when I take the sample code I am unable to get any pdf to show and cannot replicate the behaviour of the poster, but I am using python 2.7.3, PySide 1.1.1 so perhaps this is why. The error that I get when trying to run the sample code in the other post is:

QWebInspector: QSettings couldn't read configuration setting [resourceTrackingEnabled].

and the pdfs I would like to render are saved locally, in the same directory as the the python script and not accessible via the web.

Could somebody point me in the direction of some sample code or a Qt widget which I would be able to use to render a pdf?

As an aside, I am not sure that it matters but the pdf will be generated using LaTeX.

Edit --More information--

The program has to run on both Windows and Mac OSX environments but it is just for a personal project which wont be distributed. Using PyQt is not an option as it is not compatible with the python editor that I use and PySide is the requirement. I have read the following link but from what I understood under the Rendering section it said that the 3rd party libraries available worked with C, C++ and Qt not python or PySide but maybe I have misunderstood this?

Community
  • 1
  • 1
Aesir
  • 2,033
  • 1
  • 28
  • 39
  • 1
    What plaform(s) does this have to work on? What pdf plugins are available? Can you use PyQt instead of PySide? Is your application commercial (i.e. are GPL licences an issue)? Have you read [this](http://qt-project.org/wiki/Handling_PDF)? – ekhumoro Dec 07 '13 at 18:58
  • I amended my question to include more information which should cover your questions. – Aesir Dec 08 '13 at 00:05
  • 1
    I think PySide may limit your options quite a bit. For PyQt, there's [python-poppler-qt4](http://code.google.com/p/python-poppler-qt4/), which works on all the major platforms. I managed to get QWebKit to display PDFs with PySide-1.2.1 on Linux, but I had to try several plugins before seeing any success (the Okular plugin worked for me). – ekhumoro Dec 08 '13 at 00:36
  • 1
    Just tried the webkit sample code you tried on WinXP with PySide-1.1.1 and it works fine for me (using Acrobat plugin). I also see that same message, but it seems to be just a warning, not an error. – ekhumoro Dec 08 '13 at 00:53
  • How strange, I have run it on mac and windows 8 and it seems to execute fine but the actual pdf doesn't ever display. You made no amendments to it at all? – Aesir Dec 08 '13 at 12:36
  • I ran the original script (without any of the workarounds). A example pdf file that works for me, is [this one](http://www.adobe.com/products/pdfjobready/pdfs/pdftraag.pdf) (25 KiB, from the adobe website). – ekhumoro Dec 08 '13 at 17:34
  • Are you running it on a 32 or 64 bit system? I have been experimenting and I have succeeded in getting it working but only on several 32-bit computers. Every 64bit computer I have tried it on it fails to run and I get an error which says wrong architecture. – Aesir Dec 12 '13 at 16:59
  • The Linux box is 64-bit, but the WinXP is 32-bit running in a VM. I'm afraid I can't test on any other platforms at the moment. What's the exact error, and how did you install PySide on those 64-bit systems? Are you sure they're not 32-bit binaries? – ekhumoro Dec 12 '13 at 18:21

0 Answers0