How to launch pdf viewer on Mac?

P

Paul McNett

Hi,

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

os.startfile("myDocument.pdf")

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
well...

Thanks! See you at PyCon!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,044
Members
48,769
Latest member
Clifft

Latest Threads

Top