Copy link to clipboard
Copied
Hello,
I am new to javascript in PDF's. What I am trying to do is have every pair of odd and even pages have the same page number. I have written the script below but, it just returns undefined. What am I overlooking?
function addPageNumbers()
{
var sheet=1;
var x=2;
for (var i = 0; i < this.numPages; i++) {
if (x%2==0){
this.setPageLabels(i, ["D", "Back ", sheet]);
}
else{
this.setPageLabels(i, ["D", "Front ", sheet]);
sheet++;
}
x++;
}
}
You're not actually calling the function... Add this to the end of the code:
addPageNumbers();
On Mon, 15 Apr 2019 at 17:23, andreww64230743 <forums_noreply@adobe.com>
Copy link to clipboard
Copied
You're not actually calling the function... Add this to the end of the code:
addPageNumbers();
On Mon, 15 Apr 2019 at 17:23, andreww64230743 <forums_noreply@adobe.com>
Copy link to clipboard
Copied
That should have been obvious. The console is still saying undefined however.
Copy link to clipboard
Copied
That's not an error. It just means the script completed, without any return values (or errors). Did you make sure to select the whole code before running it?
Copy link to clipboard
Copied
I ran your code and it seems to work fine:
Copy link to clipboard
Copied
I didn't read the documentation well enough. The code works fine. It is naming the pages instead of printing the page number on the sheets. I wondered why I did not need to set a position....
Thanks for your help.