Skip to main content
andreww64230743
Participant
April 15, 2019
Answered

Odd and Even pages with same PageNumber

  • April 15, 2019
  • 1 reply
  • 632 views

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 has been closed for replies.
Correct answer try67

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>

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 15, 2019

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>

andreww64230743
Participant
April 15, 2019

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

try67
Community Expert
Community Expert
April 15, 2019

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?