{"id":1104,"date":"2025-12-16T09:26:34","date_gmt":"2025-12-16T16:26:34","guid":{"rendered":"https:\/\/strawhousepig.net\/wordpress\/?p=1104"},"modified":"2025-12-16T12:00:02","modified_gmt":"2025-12-16T19:00:02","slug":"place-pdf-2-up-for-perfect-bind","status":"publish","type":"post","link":"https:\/\/strawhousepig.net\/wordpress\/2025\/12\/16\/place-pdf-2-up-for-perfect-bind\/","title":{"rendered":"Place PDF 2-up for perfect bind"},"content":{"rendered":"\n<p>I don&#8217;t do perfect binding, so I don&#8217;t have or know of tools that will do what is needed to paginate for cut and stack layout. The Fiery print controller will do that, but only 2-up. Which is fine until you need 4-up. So to do that I needed a 2-up file that could then also be printed 2-up. Clear as mud, as they say.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>So no tools and no idea of tools and no desire to pay for said tools I turned to scripting InDesign, which is fairly robust. InDesign CC ships with a set of scripts in both javascript and AppleScript. I went with the AppleScript version of <code>PlaceMultipagePDF<\/code> and massaged it to do what I wanted. I&#8217;m sure a javascripter could work out a translation.<\/p>\n\n\n\n<p>How it works or expects to work: It runs through all pages of a PDF, no page selection available, but I suppose you could code it in. It starts at page &#8220;1&#8221; of an InDesign document and places page 1 of the PDF on the left half at 0 inches x and 0 inches y, creates page &#8220;2&#8221; if needed and places page 2 of the PDF on the right side at (width\/2) inches x and 0 inches y, etc. until it reaches the halfway point of the PDF pages, then it moves back to page &#8220;1&#8221;, right then left, down the document pages.<\/p>\n\n\n\n<p>It throws an error if run from Script Editor, but from the script menuextra stays silent. The {x,y} position can be hard coded of course. Relies on <code>pdfinfo<\/code> to get the number of pages in the PDF you want to place. I don&#8217;t know if <code>pdfinfo<\/code> is included in any version of macOS, but in mine it is from <a href=\"https:\/\/macports.org\/\">macports.org<\/a> as reflected by the path. [sidenote]It is also possible to export your $PATH and the start of a <code>do shell script<\/code> command in AppleScript.[\/sidenote] There is a setting for a margin. <s>Should probably be prompted for it&#8230;maybe later.<\/s> Done.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-- strawhousepig.net\n-- Based on PlaceMultipagePDF.applescript (An InDesign AppleScript)\n--\n--For more on InDesign\/InCopy scripting see the documentation included in the Scripting SDK \n--available at http:\/\/www.adobe.com\/devnet\/indesign\/sdk.html\n--or visit the InDesign Scripting User to User forum at http:\/\/www.adobeforums.com.\n--\n-- For punching or drilling holes.\nset myPDF to choose file \"Select a PDF file to place\"\ntry\n\tset myMargin to (text returned of (display dialog \"Enter amount of left-side binding margin (inch decimal).\" &amp; return &amp; return &amp; \"Your InDesign document should have twice this amount in additional width.\" default answer 0)) as integer\non error theErr\n\tdisplay alert theErr\n\treturn\nend try\nset nPDFpages to do shell script \"\/opt\/local\/bin\/pdfinfo \" &amp; quoted form of POSIX path of myPDF &amp; \" | grep Pages: | sed -E 's\/.+ (&#91;0-9]+)\/\\\\1\/'\"\nset firstHalfPDF to (round (nPDFpages \/ 2))\nset secondHalfPDF to firstHalfPDF + 1\n--log nPDFpages &amp; \" \" &amp; firstHalfPDF &amp; \" \" &amp; secondHalfPDF\ntell application \"Adobe InDesign 2025\"\n\tif (count documents) > 0 then\n\t\tset myDocument to active document\n\t\ttell myDocument to set myPage to page \"1\"\n\t\tset myStepA to 0\n\t\tset myStepB to (item 4 of bounds of myPage) \/ 2\n\t\tset oddPage to true\n\t\tset secondHalf to false\n\t\tset myCounter to 1\n\t\tset PDF crop of PDF place preferences to crop media\n\t\trepeat until myCounter = nPDFpages\n\t\t\tlog myPage\n\t\t\ttell myDocument\n\t\t\t\tif myCounter &lt; secondHalfPDF then\n\t\t\t\t\tif myCounter > 1 then\n\t\t\t\t\t\tif not (exists (every page whose name is ((((name of myPage) as integer) + 1) as string))) then\n\t\t\t\t\t\t\tset myPage to make page at after myPage\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tset myPage to (item 1 of (every page whose name is ((((name of myPage) as integer) + 1) as string)))\n\t\t\t\t\t\tend if\n\t\t\t\t\tend if\n\t\t\t\telse if myCounter > secondHalfPDF then\n\t\t\t\t\tset myPage to (item 1 of (every page whose name is ((((name of myPage) as integer) + 1) as string)))\n\t\t\t\tend if\n\t\t\tend tell\n\t\t\tif my oddPage is true then\n\t\t\t\tset myStep to myStepA\n\t\t\telse\n\t\t\t\tset myStep to myStepB\n\t\t\tend if\n\t\t\tif myMargin > 0 then\n\t\t\t\tif ((name of myPage) as integer) mod 2 = 1 then -- 0 is even, 1 is odd\n\t\t\t\t\tset myStep to myStep + myMargin\n\t\t\t\tend if\n\t\t\tend if\n\t\t\tset page number of PDF place preferences to myCounter\n\t\t\tget page number of PDF place preferences\n\t\t\ttell myPage\n\t\t\t\tset myPDFPage to place myPDF place point {myStep, 0}\n\t\t\t\tset myPDFPage to item 1 of myPDFPage\n\t\t\tend tell\n\t\t\tset oddPage to my flipper(oddPage)\n\t\t\tset myCounter to myCounter + 1\n\t\t\tif myCounter = secondHalfPDF then\n\t\t\t\ttell myDocument to set myPage to page \"1\"\n\t\t\t\tset oddPage to my flipper(oddPage)\n\t\t\t\tset secondHalf to true\n\t\t\tend if\n\t\tend repeat\n\tend if\nend tell\non flipper(bool)\n\tif bool = true then\n\t\treturn false\n\telse\n\t\treturn true\n\tend if\nend flipper\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I don&#8217;t do perfect binding, so I don&#8217;t have or know of tools that will do what is needed to paginate for cut and stack layout. The Fiery print controller will do that, but only 2-up. Which is fine until you need 4-up. So to do that I needed a 2-up file that could then [&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":[10,24,33],"class_list":["post-1104","post","type-post","status-publish","format-standard","hentry","category-code","tag-applescript-2","tag-macos","tag-script"],"_links":{"self":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/1104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/comments?post=1104"}],"version-history":[{"count":4,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/1104\/revisions"}],"predecessor-version":[{"id":1109,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/1104\/revisions\/1109"}],"wp:attachment":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/media?parent=1104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/categories?post=1104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/tags?post=1104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}