Odd and Even pages with same PageNumber

New Here ,
Apr 15, 2019 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++;

}

}

TOPICS
Acrobat SDK and JavaScript, Windows

Views

64

Likes

translate

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
community guidelines

correct answers 1 Correct Answer

Most Valuable Participant , Apr 15, 2019 Apr 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>

Likes

translate

Translate

Translate
Most Valuable Participant ,
Apr 15, 2019 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

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
community guidelines
New Here ,
Apr 15, 2019 Apr 15, 2019

Copy link to clipboard

Copied

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

Likes

translate

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
community guidelines
Most Valuable Participant ,
Apr 15, 2019 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

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
community guidelines
Most Valuable Participant ,
Apr 15, 2019 Apr 15, 2019

Copy link to clipboard

Copied

I ran your code and it seems to work fine:

Likes

translate

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
community guidelines
New Here ,
Apr 15, 2019 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

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
community guidelines