-
Notifications
You must be signed in to change notification settings - Fork 1
/
collate.js
55 lines (43 loc) · 1.57 KB
/
collate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Complements: Planet PDF (http://www.planetpdf.com/)
// Source: https://forums.adobe.com/thread/286654?start=40&tstart=0
// Modified by
// - Christian Sass for Acrobat XI compatibility
// - Bernd Alheit for newer Acrobat compatibility
// - amoshydra for comsolidating solution
// Add a menu item to reverse all pages in the active document
app.addToolButton({ cName: "Collate", cLabel: "Collate", cExec: "trustedCollatePages();", cEnable: "event.rc = (event.target != null);"});
// 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;
// insert pages from selected document into open document
for (var i = 0;i < q; i++) {
var j = i*2;
this.insertPages(j, evenDocPath, i);
}
// remove unused field
this.removeField("txtFilename");
app.endPriv();
})