[wxPython-users] Show PDF as bitmap

Paul M¢Nett p at ulmcnett.com
Fri Feb 29 18:44:55 PST 2008


Stef Mientki wrote:
> Robin Dunn wrote:
>> Algirdas Brazas wrote:
>>> An addition to that would be - how can I really show pdf on different 
>>> platforms using wx.Python's native libraries? Is that possible at 
>>> all? If not, what should I use to simply open and show pdf file in 
>>> windows and / or linux, mac?
>>
>> On windows you can display a PDF embedded in a wxPython app using the 
>> Acrobat ActiveX Control.  See the demo for an example.  There 
>> currently isn't anything similar for the other platforms, but you can 
>> execute the platform's default PDF viewer easily enough.  On Windows 
>> there is os.startfile(), and on Mac you can do os.system('open 
>> theFile.pdf') and on Linux there may be similar helper programs 
>> already installed depending on the desktop environment, or you can get 
>> the info you need from wx.TheMimeTypesManager.
> On windows pdf can also be displayed in any browser, so maybe you could 
> use IEHTML.
> I don't know for other platforms.

Here's what we do in Dabo to preview PDF's on all platforms in external 
windows. It is hackish, but it does seem to work equally well on 
Windows, Mac, and Linux.

It's the previewPDF() function at:
http://trac.dabodev.com/browser/trunk/dabo/lib/reportUtils.py#L43

I've also used the wxPDFWindow on Windows to display the pdf in my wx 
window, with good success. There's visual artifacts depending on the 
version of Acrobat, but it does look more embedded.

I'd love for there to be a cross-platform wxPDFWindow that didn't rely 
on Acrobat or IE, even on Windows. I'd contribute a small amount to a 
bounty, even.

Paul




More information about the wxpython-users mailing list