Re: PDF Viewer

37 views
Skip to first unread message

Terry Reedy

unread,
Sep 29, 2005, 5:55:21 PM9/29/05
to pytho...@python.org

"Pepe Pena" <jramir...@yahoo.com> wrote in message
news:2005092910250...@web35006.mail.mud.yahoo.com...

Google 'python pdf library' and the third hit is
www.reportlab.org/rl_toolkit.html

Terry J. Reedy

Robert Kern

unread,
Sep 29, 2005, 6:34:36 PM9/29/05
to pytho...@python.org

And is for PDF generation, not PDF viewing.

--
Robert Kern
rk...@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

John J. Lee

unread,
Sep 30, 2005, 6:55:51 PM9/30/05
to pytho...@python.org
Pepe Pena <jramir...@yahoo.com> writes:

> I am new to programming and need some guidance on the development of
> the following application. The proposed application will display
> two pdf documents simultaneously to be viewed and simple navigation
> will be facilitated (i.e. turning pages).
>
> Furthermore, the pdf documents must be linked to one another. If a
> particular page is viewed in one document, the second document will
> display a specific page.
>
> Can anyone please provide any assistance or comments on how I should
> proceed to create the mentioned application using Python within the
> windows environment, thank you.

I believe Acrobat (NOT Acrobat Reader) supports a COM interface you
could use from Python (with ctypes, maybe even with pywin32 -- not
sure if it supports IDispatch).

Alternatively, if you feel rather adventurous, try compiling KPDF on
Windows with the free Qt3 port(s?) or Qt4, if that's arrived yet. If
you're successful there, you still need to figure out writing KPart
plugins in Python, which certainly used to be tricky, but maybe that's
a solved problem by now...


Alternatively, if this was just an idea for a toy project rather than
work and you don't have Acrobat and/or lots of spare time, my advice
is to pick a different problem, and learn Ctrl-Shift-L and
Ctrl-Shift-K in Acrobat Reader instead, which have served me well in
my work at ReportLab (which does involve some work with PDF files, as
you might expect!-). Even more embarrassingly high-tech <wink>, and
even more useful for comparing two PDFs IME: holding two superimposed
printouts up to the light from a window (yes, we have a tool that lets
us do this, but the print-it-out-and-hold-it-up method seems to have
won the popularity contest, maybe thanks to the excellent "slide the
pages around" UI for comparing parts of a page that may have moved
from one file to the other...).


John

David Boddie

unread,
Sep 30, 2005, 8:26:51 PM9/30/05
to
John J. Lee wrote:

> Alternatively, if you feel rather adventurous, try compiling KPDF on
> Windows with the free Qt3 port(s?) or Qt4, if that's arrived yet.

I think you might be slightly too optimistic about getting KPDF to run
natively on Windows. The project you mention does have a page
describing how to run KDE 3.4 on Windows, but I think that may be
taking things further than the original poster intended:

http://kde-cygwin.sourceforge.net/kde3/index.php

I believe someone is working on a Qt 4 renderer for Poppler, a PDF
rendering library based on xpdf, so it could potentially be used in an
application on Windows:

http://poppler.freedesktop.org/

> If you're successful there, you still need to figure out writing KPart
> plugins in Python, which certainly used to be tricky, but maybe that's
> a solved problem by now...

Writing KPart plugins in Python (for embedding into applications) was
never all _that_ tricky; it just required some messing around with
shared libraries. As it turns out, you don't need to do this if you
just want to control KPDF from a client application written in Python.
There are two approaches you can take (for Windows users, this is
where we go off-topic):

1. Use DCOP to control two running instances of KPDF. At the simplest
level, you could use the popen2 module and the "dcop" tool to
control what KPDF displays. This could be integrated into a client
application to varying degrees, with the application getting the
window manager to do things with window placement, but it would
probably end up being a lot of effort for less than the desired
result.

http://developer.kde.org/documentation/tutorials/

2. Use the kparts module from PyKDE to display KPDF KParts in the
client application's GUI. You can still control the KParts via
their DCOP interfaces, and you can call methods on them directly
to, for example, open specific URLs or add user interface elements.

http://www.riverbankcomputing.co.uk/pykde/

Since I discovered how easy it was to embed KPDF like this, it makes
me want to experiment more with using KParts in Python. It's already
trivial to use KHTML from Python, and KParts like these could be used
to create specialised tools for documentation and visualisation.

David

Reply all
Reply to author
Forward
0 new messages