How to launch pdf viewer on Mac?

Paul McNett p at
Fri Mar 11 06:29:30 CET 2005


On Windows, os.startfile() does what I want:


That launches the default PDF viewer on the system in a separate 
process. Perfect.

On Linux, I understand that there really isn't a standard for 
determining a default application for a given file type (indeed, there 
may not even be a windowing system installed), so on that platform I've 
resorted to:

os.system("xpdf myDocument.pdf &")

But on Mac, what do I do? The user may prefer Adobe Acrobat Reader, the 
native Preview utility, or some other viewer. Actually, at this point 
I'll settle with figuring out how to launch the native Preview utility, 
but the ideal solution would let the user preference as set at the Mac 
system level determine the viewer.

While my question is "how do I launch a pdf viewer on Mac" I'll take 
constructive criticism on how I've solved this for Windows and Linux as 

Thanks! See you at PyCon!

pkm ~

More information about the Python-list mailing list