November 2, 2017 at 9:02 PM by Dr. Drang
Do you use Keyboard Maestro (or AppleScript or whatever) for one-time, throwaway macros as often as you should? I know I don’t, but I did put one together a couple of days ago and used a feature I’d never tried before.
I had one of those recalcitrant PDFs that I often get from clients. This one was 25–30 pages long, each an E-sized floor plan drawing for a building. The drawings were all black-and-white, but the PDF had color annotations added. I needed to add my own annotations to most of the pages, but something about the format of the file made it very cumbersome to work with. I tried Preview, PDF Expert, and PDfpen Pro, and they all were glacially slow when panning, zooming, and switching pages.
So I broke the file up into individual pages using PDFtk:
pdftk drawings.pdf burst
The single-page files didn’t make me wait for the spinning beach ball, so I was able to add my annotations quickly in PDF Expert. Then came an impasse.
I wanted to email the drawings with my annotations back to the client and to some other parties, but they were too big to fit in an email. I could use multiple emails, but that’s a recipe for losing some of the files. I could use a Dropbox link, but I had a sense that one of the other parties wouldn’t understand how that worked. What seemed best was to convert the files to JPEGs at the lowest legible resolution, zip them together, and send the zipped file in a single email.1
My normal practice would be to use
sips for this, because I can issue a single command to convert any number of files. But I soon learned that
sips doesn’t handle annotations properly when converting the format of a file from PDF to JPEG. In my brief testing, I found that neither my annotations or the ones that came from the client were visible in the converted JPEGs.
Preview, though, can export a PDF as a JPEG with the annotations intact and visible. Which presumably means that
sips and Preview are using different code bases for the conversion. Whatever.
The problem with using Preview is I’d have to convert every file by hand. Not the most burdensome job I’ve ever had, but one that’s boring and susceptible to error. Enter Keyboard Maestro.
Here’s the macro that exports the current file in Preview to a JPEG and closes it:
You’ll note there’s no step for setting the resolution for the exported file. That’s because once it’s set, it doesn’t change from one export to the next.
I didn’t try to have the macro open each PDF in turn, because I didn’t trust myself to do that right. I just opened all of them and then ran the macro by pressing ⌃⌥⌘J repeatedly. The macro closed each file after exporting it, leaving the next window ready to be operated on.
The new (for me) thing with this macro was the “and drag to” part at the bottom of the third step. That’s what moved the popup menu selection fromup to .
I figured out how much to drag by taking a screenshot like the one above and using a selection in Acorn to measure the vertical distance from the center of to the center of . No trial and error.
With 25–30 files to convert, it’s possible I did save time with this macro. But the main reason I made it was to avoid the tedium and the likelihood of error on my part. These are not independent—I’m far more prone to make errors when the task is repetitive and doesn’t maintain my attention.
No, a Dropbox link is really no more complicated than a zip file, but zip files are more familiar to more people. And although zipping JPEGs doesn’t make them smaller, it does package them up in a way that naive Windows users are usually comfortable with. It would be lovely if I always worked with people whose computer skills were trustworthy, but that’s not the world I live in. ↩