branch14.org

There is no easy way to duplicate pages in Acrobat. Well, unless you enhance Acrobat with the follwing script. Just put this code into a file with extension ‘.js’ and drop it into the ‘scripts’ folder of your Acrobat, and you’ll have the feature available under ‘Edit > Duplicate all pages’.
app.addMenuItem({
        cExec: "duplicate_all_pages();",
        cParent: "Edit",
        cName: "Duplicate all pages"
});

function duplicate_all_pages() {
        var r = this.getPageBox();
        var w = r[2] - r[0];
        var h = r[1] - r[3];
        var oldD = this;
        var newD = app.newDoc({ nWidth: w, nHeight: h });
        var path = oldD.path.replace(oldD.documentFileName,"");
        for(var p=oldD.numPages-1; p>=0; p--) {
                pageFile = path+"page_"+p+".pdf";
                oldD.extractPages({ cPath: pageFile, nStart: p });
                newD.insertPages({ cPath: pageFile, nPage: -1 });
                newD.insertPages({ cPath: pageFile, nPage: -1 });
                //File.delete(pageFile);
        }
        return true;
}

duplicate all pages in acrobat

  • snippet type: utility, plugin
  • keywords: acrobat, pdf, duplication
  • language: javascript

Once I had a scan of a book that needed some reformatting to meet the requirements for lulu.com to print it to a book. For that reason i needed Adobe Acrobat Pro to be able to duplicate each page of my document. Out of the box Acrobat lacks such a feature, so i coded it up in javascript. Afterwards I simply could use the ‘Crop Tool’ twice, once on the odd pages and once on the even pages to do the final reformatting. (Please be aware that the script is creating a PDF file for each page.)

all snippets