start default application for read a pdf from python

Albert Hopkins marduk at letterboxes.org
Tue Sep 8 19:22:10 EDT 2009


On Tue, 2009-09-08 at 22:22 +0200, Angelo Ballabio wrote:
> My problem is a way to run a default application to read and show a
> pdf 
> file from unix or windows, i have a mixed ambient in the office, so I
> am 
> try to find a way to start a application to show this pdf file I 
> generate whith reportlab. 

The (most) portable way to do so in Linux (not necessarily Unix) is to
use the xdg-open command.  Ex, 

    subprocess.Popen(['xdg-open', 'my-document.pdf'])

If you want cross-platform between Linux/Windows, then it's advisable to
write a wrapper function that checks the value of sys.platform and and
acts accordingly.

-a





More information about the Python-list mailing list