Vincent Ballenegger
Physicist, senior lecturer (maître de conférences)

MacOS scripts

Here are some convenient small scripts, packaged as quick actions, that I use to accelerate frequent tasks on MacOS.

Finder



Terminal

Export as PDF a figure drawn in Keynote without any blank margin

I often use Keynote a draw simple vector graphics, typically to illustrate a physical system and the definition of variables. Keynote is convenient for this task because it has a good support for LaTeX equations/labels. A drawback is that Keynote exports the page (the single slide) with white margins around the figure, whereas I need a PDF figure without any white margin. (The Finder quick action Trim PDF image, see above, allows to get rid quickly of the margins, but it would be better not to have any white margin from the beginning.)

To optimize this workflow, I've created a PDF Service for MacOS called Save as PDF & trim. It provides a command Save as PDF & trim in the Print dialog. That command saves directly a trimed PDF image in the standard 'Downloads' folder. A keyboard shortcut (e.g. ⌘S) can also be set so there is no need to even open the 'PDF' drop-down menu in the Print dialog (to set the shortcut, go to MacOS System Preferences, section Keyboard shortcuts -> Application shortcuts -> Save as PDF & trim). This PDF Service requires the program K2pdfopt to be installed. As I hard-coded the path to this program, adjust it in the script before using it (open the script in Automator to do this).