Skip to main content
andreww64230743
Participant
Apr 15, 2019 3:22 PM UTC
Answered

Odd and Even pages with same PageNumber

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++;

}

}

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Apr 15, 2019 3:29 PM UTC

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>

5 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Apr 15, 2019 3:29 PM UTC

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>

Translate
andreww64230743
Participant
Apr 15, 2019 3:45 PM UTC

That should have been obvious. The console is still saying undefined however.

Translate
try67
Community Expert
Community Expert
Apr 15, 2019 3:55 PM UTC

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?

Translate