Copy link to clipboard
Copied
Hello everyone!
I need a help. I need to duplicate a page X times. Does it means that I want to be able to choose how many times I want to duplicate the page.
I found an interesting script that does it but it duplicate ALL the page of the document while I need to duplicate ONLY the active page.
I have tried to modify the script but I couldn't.
Can anyone help me?
this is the script I found
var n = prompt('Enter a number between 1 and 99.', '', 'Name of dialog');
var reg = /^\d{2}$/;
if (reg.test(n)){
var doc = app.documents[0];
var nbPage = doc.pages.length; // count doc pages
for (i = 0; i < nbPage; i++) {
var sourcePage = doc.pages.item(i + (i*n));
for (j = 0; j < n; j++) {
sourcePage.duplicate(LocationOptions.AFTER, doc.pages.item(i + (i*n)));
}
}
}else{
alert('Error \r Must be a number between 1 to 99');
}
Hi,
Try following snippet for duplicating the activePage. Below script, active page will duplicate n times after active page.
var n = prompt('Enter how many times you want to duplicate', '', 'Name of dialog');
var reg = /^\d$/;
if (reg.test(n)) {
var doc = app.documents[0];
var activePage = app.layoutWindows[0].activePage
for (i = 0; i < n; i++) {
activePage.duplicate(LocationOptions.AFTER, activePage);
}
} else {
alert('Error \r Must be a number between 1 to 99');
}
Copy link to clipboard
Copied
Hi,
Try following snippet for duplicating the activePage. Below script, active page will duplicate n times after active page.
var n = prompt('Enter how many times you want to duplicate', '', 'Name of dialog');
var reg = /^\d$/;
if (reg.test(n)) {
var doc = app.documents[0];
var activePage = app.layoutWindows[0].activePage
for (i = 0; i < n; i++) {
activePage.duplicate(LocationOptions.AFTER, activePage);
}
} else {
alert('Error \r Must be a number between 1 to 99');
}
Copy link to clipboard
Copied
it works
thanks