Cropping PDFs with AppleScript

Due to Coronavirus the printing of our yearbooks was delayed, so we decided to distribute it digitally until the print version was available. There are lots of tools, like ISSUU, Uberflip, or even Google Drive that can do a decent job of displaying a PDF, password protecting it, and preventing it from being downloaded. The challenge was to get the galley proofs with crop marks, etc. into the right format. Further complicating things were that the odd/even pages had crop markets that were offset, so they had to be cropped differently.

Here is an example of a page with the dotted crop marks and the metadata on the bottom.

Fortunately Adobe Acrobat is scriptable. Normally, I tend to avoid installing Acrobat, in favor of using Preview, but its support for scripting is surprisingly good. The follow AppleScript crops odd/even pages differently and solved my problem. (based on https://macscripter.net/viewtopic.php?id=32586)

tell application "Adobe Acrobat"
activate tell active doc repeat with i from 1 to count of pages tell page i set {L, T, R, B} to media box if ((i mod 2) = 0) then set crop box to {L + 37, T - 39, R, B + 156} else set crop box to {L, T - 39, R - 37, B + 156} end if end tell end repeat end tell end tell

Leave a Reply

Your email address will not be published. Required fields are marked *