• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

319

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

Community Expert , 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>

Votes

Translate

Translate
Community Expert ,
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>

Votes

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.

Votes

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
Community Expert ,
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?

Votes

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
Community Expert ,
Apr 15, 2019 Apr 15, 2019

Copy link to clipboard

Copied

I ran your code and it seems to work fine:

Votes

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

LATEST

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.

Votes

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