├── closeAllWithoutSaving.js ├── createOnePagePdfs.js ├── reversePdf.js ├── createTwoPagePdfs.js ├── reverseAllPdfs.js ├── README.md ├── mergeOddEvenPdf.js └── mergeOddReverseEvenPdf.js /closeAllWithoutSaving.js: -------------------------------------------------------------------------------- 1 | // Created by Nathaniel Young (nyoungstudios on GitHub) 2 | // this script closes all PDF documents without asking the user if they want to save it 3 | 4 | // anonymous wrapper function 5 | (function() { 6 | 7 | // gets the active documents with the first one being the odd and second one being the even document 8 | var activeDocs = app.activeDocs; 9 | 10 | // loops over all documents that are open 11 | for (var i = 0; i < activeDocs.length; i++) { 12 | // gets the current document object 13 | var currDoc = activeDocs[i]; 14 | 15 | // closes document without save notification 16 | currDoc.closeDoc(true); 17 | 18 | } 19 | 20 | })(); -------------------------------------------------------------------------------- /createOnePagePdfs.js: -------------------------------------------------------------------------------- 1 | // Created by Nathaniel Young (nyoungstudios on GitHub) 2 | // this script creates a new one page pdf document for each pdf page in the current focused pdf 3 | 4 | // anonymous wrapper function 5 | (function() { 6 | 7 | // gets the current document object 8 | var currDoc = this; 9 | 10 | // gets the page length of the documents 11 | var lenCurrDoc = currDoc.numPages; 12 | 13 | // for the length of the document, insert page into new document 14 | for (var j = 0; j < lenCurrDoc; j ++) { 15 | // Create new PDF document 16 | var newDoc = app.newDoc(); 17 | newDoc.insertPages({ 18 | nPage: 0, 19 | cPath: currDoc.path, 20 | nStart: j, 21 | nEnd: j 22 | }); 23 | 24 | // deletes initial blank page 25 | newDoc.deletePages(); 26 | } 27 | 28 | })(); -------------------------------------------------------------------------------- /reversePdf.js: -------------------------------------------------------------------------------- 1 | // Created by Nathaniel Young (nyoungstudios on GitHub) 2 | // this script creates a new pdf by reversing the currently focused pdf 3 | 4 | // anonymous wrapper function 5 | (function() { 6 | 7 | // gets the current document object 8 | var currDoc = this; 9 | 10 | // gets the page length of the documents 11 | var lenCurrDoc = currDoc.numPages; 12 | 13 | // Create new PDF document 14 | var newDoc = app.newDoc(); 15 | 16 | // for the length of the document, insert page into new document 17 | for (var j = 0; j < lenCurrDoc; j ++) { 18 | newDoc.insertPages({ 19 | nPage: j, 20 | cPath: currDoc.path, 21 | nStart: lenCurrDoc - j - 1, 22 | nEnd: lenCurrDoc - j - 1 23 | }); 24 | } 25 | 26 | // deletes initial blank page 27 | newDoc.deletePages(); 28 | 29 | })(); -------------------------------------------------------------------------------- /createTwoPagePdfs.js: -------------------------------------------------------------------------------- 1 | // Created by Nathaniel Young (nyoungstudios on GitHub) 2 | // this script creates a new two page pdf document for each two pdf pages in the current focused pdf 3 | // if there is an odd number of pages, then it puts the left over page in a new document 4 | 5 | // anonymous wrapper function 6 | (function() { 7 | 8 | // gets the current document object 9 | var currDoc = this; 10 | 11 | // gets the page length of the documents 12 | var lenCurrDoc = currDoc.numPages; 13 | 14 | // for the length of the document, insert page into new document 15 | for (var j = 0; j < lenCurrDoc; j +=2) { 16 | 17 | // Create new PDF document 18 | var newDoc = app.newDoc(); 19 | newDoc.insertPages({ 20 | nPage: 0, 21 | cPath: currDoc.path, 22 | nStart: j, 23 | nEnd: j < lenCurrDoc - 1? j + 1 : j 24 | }); 25 | 26 | // deletes initial blank page 27 | newDoc.deletePages(); 28 | 29 | } 30 | 31 | })(); -------------------------------------------------------------------------------- /reverseAllPdfs.js: -------------------------------------------------------------------------------- 1 | // Created by Nathaniel Young (nyoungstudios on GitHub) 2 | // this script creates new pdfs by reversing all the open pdfs 3 | 4 | // anonymous wrapper function 5 | (function() { 6 | 7 | // gets the active documents with the first one being the odd and second one being the even document 8 | var activeDocs = app.activeDocs; 9 | 10 | // reverse the pages for all the documents that are open 11 | for (var i = 0; i < activeDocs.length; i++) { 12 | // gets the current document object 13 | var currDoc = activeDocs[i]; 14 | 15 | // gets the page length of the documents 16 | var lenCurrDoc = currDoc.numPages; 17 | 18 | // Create new PDF document 19 | var newDoc = app.newDoc(); 20 | 21 | // for the length of the document, insert page into new document 22 | for (var j = 0; j < lenCurrDoc; j ++) { 23 | newDoc.insertPages({ 24 | nPage: j, 25 | cPath: currDoc.path, 26 | nStart: lenCurrDoc - j - 1, 27 | nEnd: lenCurrDoc - j - 1 28 | }); 29 | } 30 | 31 | // deletes initial blank page 32 | newDoc.deletePages(); 33 | 34 | } 35 | 36 | })(); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Adobe Acrobat PDF Tools 2 | I graduated from college and decided to digitize some of my school work instead of saving a hard copy. Unfortunately, my scanner can only scan one side at a time; therefore, merging the even and odd pages would be a highly time consuming and manual process. So I wrote these scripts to do it for me. 3 | 4 | The "Merge Two PDFs by alternating Odd and Reverse Even Pages" is probably the most relevent script if you are scanning a book, journal, magazine, etc. since the even page numbers typically are scanned in backwards. 5 | 6 | ## Features 7 | * Merge Two PDFs by alternating Odd and Even Pages 8 | * Merge Two PDFs by alternating Odd and Reverse Even Pages 9 | * Reverse Page Order of all Open PDFs 10 | * Reverse Page Order of Currently Focused (or selected) PDF 11 | * Create new PDFs for each page of Currently Focused PDF 12 | * Create new two page PDFs starting with every other page of Currently Focused PDF 13 | * Closes all open PDFs without asking to save them 14 | 15 | ## How to install? 16 | 1. Download the XmlData.zip of the [latest release](https://github.com/nyoungstudios/Adobe-Acrobat-PDF-Tools/releases), and unzip the folder. 17 | 2. Open Adobe Acrobat, and open the Action Wizard tool. 18 | 3. Then, click the "Manage Custom Commands" tab. 19 | 4. On the new popup window, click import and select the XML Documents you want to install. 20 | 21 | ## How to use? 22 | If you are using either of the merge PDF scripts, make sure to close all PDF documents. Then, open the odd document first. And then the even document afterwards. The order is important so the script knows which document to put as the odd and even document. In the future, I hope to make it a little more user friendly like Adobe's built in Combine Files tool. 23 | 24 | As for the Reverse Page Order scripts, they do not have any restrictions. 25 | 26 | ## Notes 27 | Tested on Adobe Acrobat Pro DC (as part of the Adobe Creative Cloud).\ 28 | For the merge PDF scripts if the pages are different lengths, then it will just append the rest of the pages without alternating at the end.\ 29 | All scripts create a new document rather than modifying the original documents. 30 | -------------------------------------------------------------------------------- /mergeOddEvenPdf.js: -------------------------------------------------------------------------------- 1 | // Created by Nathaniel Young (nyoungstudios on GitHub) 2 | // this script creates a new pdf by merging the even and odd pages 3 | // in other words, creates new pdf by inserting alternating pages from each source 4 | // must open the odd pages pdf before the even pages pdf 5 | 6 | // anonymous wrapper function 7 | (function() { 8 | 9 | // gets the active documents with the first one being the odd and second one being the even document 10 | var activeDocs = app.activeDocs; 11 | if (activeDocs.length < 2) { 12 | app.alert('Need to open two PDFs.'); 13 | return; 14 | } 15 | 16 | var oddDoc = activeDocs[0]; 17 | var evenDoc = activeDocs[1]; 18 | 19 | // gets the page length of the documents 20 | var lenOddDoc = oddDoc.numPages; 21 | var lenEvenDoc = evenDoc.numPages; 22 | 23 | // Create new PDF document 24 | var newDoc = app.newDoc(); 25 | 26 | // index counters 27 | index = 0; 28 | oddIndex = 0; 29 | evenIndex = 0; 30 | 31 | // inserts the pages alternating from each pdf source 32 | while (oddIndex != lenOddDoc && evenIndex != lenEvenDoc) { 33 | if (index % 2 == 0) { 34 | newDoc.insertPages({ 35 | nPage: index, 36 | cPath: oddDoc.path, 37 | nStart: oddIndex, 38 | nEnd: oddIndex 39 | }); 40 | oddIndex++; 41 | } else { 42 | newDoc.insertPages({ 43 | nPage: index, 44 | cPath: evenDoc.path, 45 | nStart: evenIndex, 46 | nEnd: evenIndex 47 | }); 48 | evenIndex++; 49 | 50 | } 51 | 52 | // console.println('index: ' + index + ' odd: ' + oddIndex + ' even: ' + evenIndex); 53 | 54 | index++; 55 | 56 | } 57 | 58 | // appends the leftover pages if pdf lengths are not equal 59 | if (oddIndex != lenOddDoc) { 60 | newDoc.insertPages({ 61 | nPage: index, 62 | cPath: oddDoc.path, 63 | nStart: oddIndex, 64 | nEnd: lenOddDoc - 1 65 | }); 66 | } else if (evenIndex != lenEvenDoc) { 67 | newDoc.insertPages({ 68 | nPage: index, 69 | cPath: evenDoc.path, 70 | nStart: evenIndex, 71 | nEnd: lenEvenDoc - 1 72 | }); 73 | } 74 | 75 | // deletes initial blank page 76 | newDoc.deletePages(); 77 | 78 | })(); -------------------------------------------------------------------------------- /mergeOddReverseEvenPdf.js: -------------------------------------------------------------------------------- 1 | // Created by Nathaniel Young (nyoungstudios on GitHub) 2 | // this script creates a new pdf by merging the odd and reverse even pages which may be necessary due to how the scanner scans the pages 3 | // in other words, creates new pdf by inserting alternating pages from each source 4 | // must open the odd pages pdf before the reverse even pages pdf 5 | 6 | // anonymous wrapper function 7 | (function() { 8 | 9 | // gets the active documents with the first one being the odd and second one being the even document 10 | var activeDocs = app.activeDocs; 11 | if (activeDocs.length < 2) { 12 | app.alert('Need to open two PDFs.'); 13 | return; 14 | } 15 | 16 | var oddDoc = activeDocs[0]; 17 | var evenDoc = activeDocs[1]; 18 | 19 | // gets the page length of the documents 20 | var lenOddDoc = oddDoc.numPages; 21 | var lenEvenDoc = evenDoc.numPages; 22 | 23 | // Create new PDF document 24 | var newDoc = app.newDoc(); 25 | 26 | // index counters 27 | index = 0; 28 | oddIndex = 0; 29 | evenIndex = lenEvenDoc; 30 | 31 | // inserts the pages alternating from each pdf source 32 | while (oddIndex != lenOddDoc && evenIndex != 0) { 33 | if (index % 2 == 0) { 34 | newDoc.insertPages({ 35 | nPage: index, 36 | cPath: oddDoc.path, 37 | nStart: oddIndex, 38 | nEnd: oddIndex 39 | }); 40 | oddIndex++; 41 | } else { 42 | newDoc.insertPages({ 43 | nPage: index, 44 | cPath: evenDoc.path, 45 | nStart: evenIndex - 1, 46 | nEnd: evenIndex - 1 47 | }); 48 | evenIndex--; 49 | 50 | } 51 | 52 | // console.println('index: ' + index + ' odd: ' + oddIndex + ' even: ' + evenIndex); 53 | 54 | index++; 55 | 56 | } 57 | 58 | // appends the leftover pages if pdf lengths are not equal 59 | if (oddIndex != lenOddDoc) { 60 | newDoc.insertPages({ 61 | nPage: index, 62 | cPath: oddDoc.path, 63 | nStart: oddIndex, 64 | nEnd: lenOddDoc - 1 65 | }); 66 | } else if (evenIndex != 0) { 67 | while (evenIndex != 0) { 68 | newDoc.insertPages({ 69 | nPage: index, 70 | cPath: evenDoc.path, 71 | nStart: evenIndex - 1, 72 | nEnd: evenIndex - 1 73 | }); 74 | index++; 75 | evenIndex--; 76 | } 77 | } 78 | 79 | // deletes initial blank page 80 | newDoc.deletePages(); 81 | 82 | })(); --------------------------------------------------------------------------------