Friday, September 23, 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:
        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--) {
            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.

1 comment:

Matthew Leingang said...

Thanks very much for this! For my purposes it's better to edit the document in place than create a new file as I was before.

Rather than create a javascript file and save it in the application's scripts directory I just used the Action Wizard and created an action with the code inside your function block.