Last active
December 18, 2025 12:23
-
-
Save eldon/0eb0f54798b3393522dc6206ca5b219a to your computer and use it in GitHub Desktop.
Mirroring the CollagePages script from here for future use: https://forums.adobe.com/thread/286654#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Complements: Planet PDF (http://www.planetpdf.com/) | |
| // Modified by Jeff Baitis for Acrobat 9 and Acrobat X compatibility | |
| // Improved Collate function with status bar. | |
| // Add a menu item to reverse all pages in the active document | |
| app.addMenuItem({ cName: "Reverse", cParent: "Edit", cExec: "trustedReversePages();", cEnable: "event.rc = (event.target != null);", nPos: 0 }); | |
| // Add a menu item to collate with another document on the filesystem | |
| app.addMenuItem({ cName: "Collate", cParent: "Edit", cExec: "trustedCollatePages();", cEnable: "event.rc = (event.target != null);", nPos: 0 }); | |
| trustedReversePages = app.trustedFunction(function() | |
| { | |
| app.beginPriv(); // Explicitly raise privileges | |
| var t = app.thermometer; | |
| t.duration = this.numPages; | |
| t.begin(); | |
| for (i = this.numPages - 1; i >= 0; i--) | |
| { | |
| t.value = (i-this.numPages)*-1; | |
| this.movePage(i); | |
| t.text = 'Moving page ' + (i + 1); | |
| } | |
| t.end(); | |
| app.endPriv(); | |
| }) | |
| // Collating pages | |
| /* | |
| Title: Collate Document | |
| Purpose: User is prompted to select document to insert/collate. | |
| Author: Sean Stewart, ARTS PDF, www.artspdf.com | |
| */ | |
| trustedCollatePages = app.trustedFunction(function() | |
| { | |
| app.beginPriv(); // Explicitly raise privileges | |
| // create an array to use as the rect parameter in the browse for field | |
| var arRect = new Array(); | |
| arRect[0] = 0; | |
| arRect[1] = 0; | |
| arRect[2] = 0; | |
| arRect[3] = 0; | |
| // create a non-visible form field to use as a browse for field | |
| var f = this.addField("txtFilename", "text", this.numPages - 1, arRect); | |
| f.delay = true; | |
| f.fileSelect = true; | |
| f.delay = false; | |
| // user prompted to select file to collate the open document with | |
| app.alert("Select the PDF file to merge with") | |
| // open the browse for dialog | |
| f.browseForFileToSubmit(); | |
| var evenDocPath = f.value; | |
| var q = this.numPages; | |
| var t = app.thermometer; | |
| t.duration = q; | |
| t.begin(); | |
| // insert pages from selected document into open document | |
| for (var i = 0; i < q; i++) { | |
| var j = i*2; | |
| this.insertPages(j, evenDocPath, i); | |
| t.value = i; | |
| t.text = 'Inserting page ' + (i+1); | |
| } | |
| t.end(); | |
| // remove unused field | |
| this.removeField("txtFilename"); | |
| app.endPriv(); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment