Odd and Even pages with same PageNumber

New Here ,
Apr 15, 2019

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

}

}

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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>

TOPICS
Acrobat SDK and JavaScript, Windows

Views

61

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Odd and Even pages with same PageNumber

New Here ,
Apr 15, 2019

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

}

}

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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>

TOPICS
Acrobat SDK and JavaScript, Windows

Views

62

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 15, 2019 0
Most Valuable Participant ,
Apr 15, 2019

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>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 15, 2019 0
New Here ,
Apr 15, 2019

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 15, 2019 0
Most Valuable Participant ,
Apr 15, 2019

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 15, 2019 0
Most Valuable Participant ,
Apr 15, 2019

Copy link to clipboard

Copied

I ran your code and it seems to work fine:

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 15, 2019 0
New Here ,
Apr 15, 2019

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 15, 2019 0