Hi
I'm try to create a javascript menu option, so that when a user opens any PDF file, they can click DUPLICATE PAGE from the Edit drop down.
It would then automatcially duplicate the one page document 4 times, so the PDF file now containes 5 pages within the same document.
I have used this script, which does the job but creates a 6th blank page and also throws an error after running,
I have no javascript experience, so pls be gentle/
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 });
newD.insertPages({ cPath: pageFile, nPage: -1 });
newD.insertPages({ cPath: pageFile, nPage: -1 });
newD.insertPages({ cPath: pageFile, nPage: -1 });
}
return true;
}