23.9.2011

Duplicate All Pages (in-place) in Acrobat X

This is just a small JavaScript extension to Acrobat X that allowes to Duplicate all pages in-place there exists another version which used extractPages and I didn't like that behavior so I wrote own.

First elevate privileges of the JavaScript programs:

  1. Right click on document, and choose "Page Display Preferences"
  2. Choose "JavaScript" from the left.
  3. Check the "Enable menu items JavaScript execution privileges".

Secondly save following snippet as duplicate.js to the %appdata%\Adobe\Acrobat\10.0\JavaScripts folder:

app.addMenuItem({  
        cExec: "duplicatePagesInPlace();",  
        cParent: "Edit",  
        cName: "Duplicate all pages (in-place)"  
});  
  
function duplicatePagesInPlace() {  
    var doc = this,  
        pages = this.numPages;  
    for (var i = pages - 1; i >= 0; i--) {  
        doc.insertPages({   
            cPath: doc.path,   
            nStart : i,   
            nEnd : i,  
            nPage : i  
        });  
    }  
}  

Now you should be able to access the "Duplicate all pages (in-place)" under "Edit" menu item. If you can't see the item remember to restart Acrobat.

← Back to blog