Show PDF as bitmap

Hi all,

How could I show a PDF file in my window without letting the user to select text or graphics? At the moment I take a TXT file and manualy rewrite it to XML, then parse that XML and write the text onscreen in wx.DC as a simple bitmap...

Algirdas Brazas

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

Algirdas Brazas escribió:

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?

Time ago I found a general purpose solution similar to os.startfile()
that at least works on linux (not tested on other platforms). Code is
attached. For a quick test just put a file called test.pdf in /tmp and
run the attachment.

pdfview.py (639 Bytes)

···

Algirdas
----- Original Message ----- From: "Algirdas Brazas" <lists@digital.ktu.lt>
To: <wxPython-users@lists.wxwidgets.org>
Sent: Saturday, March 01, 2008 12:26 AM
Subject: [wxPython-users] Show PDF as bitmap

Hi all,

How could I show a PDF file in my window without letting the user to
select text or graphics? At the moment I take a TXT file and manualy
rewrite it to XML, then parse that XML and write the text onscreen in
wx.DC as a simple bitmap...

Algirdas Brazas

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org