Open Current PDF Document in Another PDF Reader App, With Prompt to Set App as Default for PDFs

This macro is another take on @Mirizzi's previously posted "Open In" macro. Like Mirizzi, I wanted to be able to quickly open the current PDF document in another PDF reader app.

OPEN CURRENT DOCUMENT IN CHOSEN PDF READER.kmmacros (15.8 KB) - UPLOADED IN DISABLED STATE

This macro assumes that the open PDF document is being viewed in Preview, and the "open in" options are Skim, PDF Expert, and Acrobat. The macro can be adapted for use with the other PDF apps. (Caveat: PDF Expert is tricky. If you want more info about how to make it work in PDF Expert, let me know.)

This macro first gets the path of the open PDF document by leveraging @ccstone's wonderful Applescript:

image

Then, the user is prompted via list to choose the PDF app into which to open the document:

image

After opening the document in the new PDF app, the macro then closes the document in the previous app and returns to the document in the newly opened app:

image

Finally, the macro prompts the user to set the newly opened PDF app as the default app for PDFs:

image

This last aspect of the macro leverages a Swift script posted by @Tom in a comment in this post a few years ago. The key insight:

Tom also kindly provided a simple macro for getting the bundle ID of any app so as to insert it into the Swift script.

Should you want to create an option to set Preview as the default PDF app, the Swift script would be:

import Foundation

LSSetDefaultRoleHandlerForContentType("com.adobe.pdf" as CFString, LSRolesMask.all, "com.apple.Preview" as CFString)

It would look like this in the macro:

image

Cheers!