PDF Shortcut Examples

This shortcut extracts specified pages and page ranges from a PDF file selected in a Finder window. It is similar to the shortcut in post 1 above, except that multiple pages and page ranges can be extracted, Also this shortcut contains additional error correction, although it does not check the number of pages in the source PDF. The following screenshot only shows a portion of the shortcut.

PDF Extract.shortcut (25.5 KB)

Here’s another approach to get the number of pages in a PDF. This works if the PDF is on a drive that’s not indexed, but it’s slow.

PDF Page Count.shortcut (22.0 KB)

The shortcut included below is similar to that noted above, differing only in that the shortcut works on a PDF being viewed in the Preview app. I successfully ran the shortcut on macOS 26.3 by way of: Spotlight; menu-bar shortcut collection; menu-bar shortcut icon; AppleScript in the AppleScript menu; and AppleScript and shell script in FastScripts. I was unable to run the shortcut by way of the Preview app Services menu and a keyboard shortcut set in the Shortcuts app.

I was uncertain what should happen after the PDF pages are extracted and saved. Options I considered are:

  • Open the new PDF in a Preview window.

  • Open a Finder window with the new PDF selected.

  • Show a notification.

  • Do nothing.

As written, the shortcut shows a notification.

PDF Extract.shortcut (25.3 KB)

The following shortcut is identical to that above with two exceptions. First, consecutive sequential pages and page ranges entered by the user are combined (e.g. “1 2-3 4” is made into “1-4”). This change is reflected in the file name and notification. Secondly, an existing file (which is never the PDF being viewed) is always overwritten by the saved file with the extracted pages. The shell script in the shortcut was written by Nigel.

PDF Extract.shortcut (26.2 KB)

BTW, if the user enters a page number that does not exist in the source PDF, one or more blank pages may be included in the newly-created PDF. The shortcut can be edited to prevent this, but its operation would be slowed considerably.

Both of the shortcuts in the prior post do not work correctly if two or more PDFs are being viewed in the Preview app. There’s no fix for this that I could find, so the following shortcut alerts the user and stops if two or more PDFs are viewed.

PDF Extract.shortcut (26.6 KB)