-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreverseAllPdfs.js
36 lines (27 loc) · 1012 Bytes
/
reverseAllPdfs.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
// Created by Nathaniel Young (nyoungstudios on GitHub)
// this script creates new pdfs by reversing all the open pdfs
// anonymous wrapper function
(function() {
// gets the active documents with the first one being the odd and second one being the even document
var activeDocs = app.activeDocs;
// reverse the pages for all the documents that are open
for (var i = 0; i < activeDocs.length; i++) {
// gets the current document object
var currDoc = activeDocs[i];
// gets the page length of the documents
var lenCurrDoc = currDoc.numPages;
// Create new PDF document
var newDoc = app.newDoc();
// for the length of the document, insert page into new document
for (var j = 0; j < lenCurrDoc; j ++) {
newDoc.insertPages({
nPage: j,
cPath: currDoc.path,
nStart: lenCurrDoc - j - 1,
nEnd: lenCurrDoc - j - 1
});
}
// deletes initial blank page
newDoc.deletePages();
}
})();