Open PDF

Martin Miller ggrp1.20.martineau at
Fri Sep 23 20:55:28 CEST 2005

IMHO, the fact that there is no way to wait for the application to
finish is major deficiency with os.startfile() -- and why I often
cannot use it instead of other techniques [such as the much more
involved but limited os.spawnv() function].

I don't if if this is just a limitation of the implementation in the
Python os module or one with the underlying OS (Windoze) -- I suspect
the latter.


Dennis Lee Bieber wrote:
> On Thu, 22 Sep 2005 15:16:09 +0100, Dan <dan at> declaimed
> the following in comp.lang.python:
> > > I would like to know how to open a PDF document from a python script
> >
> > You mean open it and display it to the user? Under Windows you may be
> > able to get away with just "executing" the file (as though it were an
> > executable):
> >
> >   import os
> >   os.system("c:/path/to/file.pdf")
> 	For Windows, os.startfile() may be better...
> >>> help(os.startfile)
> Help on built-in function startfile:
> startfile(...)
>     startfile(filepath) - Start a file with its associated application.
>     This acts like double-clicking the file in Explorer, or giving the
> file
>     name as an argument to the DOS "start" command:  the file is opened
>     with whatever application (if any) its extension is associated.
>     startfile returns as soon as the associated application is launched.
>     There is no option to wait for the application to close, and no way
>     to retrieve the application's exit status.
>     The filepath is relative to the current directory.  If you want to
> use
>     an absolute path, make sure the first character is not a slash
> ("/");
>     the underlying Win32 ShellExecute function doesn't work if it is.
> >>>

More information about the Python-list mailing list