{"id":153,"date":"2020-05-25T17:32:48","date_gmt":"2020-05-25T17:32:48","guid":{"rendered":"http:\/\/duff.io\/?p=153"},"modified":"2020-05-25T17:32:48","modified_gmt":"2020-05-25T17:32:48","slug":"cropping-pdfs","status":"publish","type":"post","link":"https:\/\/duff.io\/?p=153","title":{"rendered":"Cropping PDFs with AppleScript"},"content":{"rendered":"\n<p>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.<\/p>\n\n\n\n<p>Here is an example of a page with the dotted crop marks and the metadata on the bottom.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1300\" height=\"1950\" src=\"https:\/\/i1.wp.com\/duff.io\/wp-content\/uploads\/2020\/05\/sample.png?fit=660%2C990\" alt=\"\" class=\"wp-image-161\" srcset=\"https:\/\/duff.io\/wp-content\/uploads\/2020\/05\/sample.png 1300w, https:\/\/duff.io\/wp-content\/uploads\/2020\/05\/sample-200x300.png 200w, https:\/\/duff.io\/wp-content\/uploads\/2020\/05\/sample-683x1024.png 683w, https:\/\/duff.io\/wp-content\/uploads\/2020\/05\/sample-768x1152.png 768w, https:\/\/duff.io\/wp-content\/uploads\/2020\/05\/sample-1024x1536.png 1024w\" sizes=\"auto, (max-width: 1300px) 100vw, 1300px\" \/><\/figure>\n\n\n\n<p>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 <a href=\"https:\/\/macscripter.net\/viewtopic.php?id=32586\">https:\/\/macscripter.net\/viewtopic.php?id=32586<\/a>)<\/p>\n\n\n<p><\/p>\n<pre class=\"brush: applescript\">tell application \"Adobe Acrobat\"<br>\n\tactivate\n\ttell active doc\n\t\trepeat with i from 1 to count of pages\n\t\t\ttell page i\n\t\t\t\tset {L, T, R, B} to media box\n\t\t\t\tif ((i mod 2) = 0) then\n\t\t\t\t\tset crop box to {L + 37, T - 39, R, B + 156}\n\t\t\t\telse\n\t\t\t\t\tset crop box to {L, T - 39, R - 37, B + 156}\n\t\t\t\tend if\n\t\t\tend tell\n\t\tend repeat\n\tend tell\nend tell\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-153","post","type-post","status-publish","format-standard","hentry","category-applescript"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/posts\/153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/duff.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=153"}],"version-history":[{"count":1,"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/posts\/153\/revisions"}],"predecessor-version":[{"id":174,"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/posts\/153\/revisions\/174"}],"wp:attachment":[{"href":"https:\/\/duff.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/duff.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/duff.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}