Skip to main content
Participating Frequently
October 10, 2013
Answered

Mathematic Calculation with Current page numbering

  • October 10, 2013
  • 1 reply
  • 893 views

Hi,

Currently I am in situation where I need 2 types of page numbers for one single page.

For the right side I am using the current page number marker.

Is there a way to do mathematic calculation with current page number on the left side?

Something like 460+current page number

I cant use the data merge feature because all the page are already layed out.

Regards.

This topic has been closed for replies.
Correct answer Jump_Over

Hi,

You could run a script:

app.findGrepPreferences = null;

app.findGrepPreferences.findWhat = "~N";

var

     FindGrep=app.activeDocument.findGrep(),

     len = FindGrep.length,

     item, pageNo, calcNo, rightSide,

     mDiff = 460;          // edit this value according to needs

     while (len-->0) {

          item = FindGrep[len];

          pageNo = item.parentTextFrames[0].parentPage.name;

          calcNo = parseInt(pageNo) + mDiff;

          item.paragraphs[0].contents = calcNo + "\t" + pageNo;

          rightSide = item.parentTextFrames[0].textFramePreferences.textColumnFixedWidth;

          with (item.paragraphs[0]) {

               tabStops.add({alignment: TabStopAlignment.RIGHT_ALIGN, position: rightSide});

               justification = Justification.LEFT_ALIGN;

               }

          }

which should work assuming textFrames with pageNumbers are overridden (accessible)

Jarek

1 reply

Jump_Over
Jump_OverCorrect answer
Brainiac
October 10, 2013

Hi,

You could run a script:

app.findGrepPreferences = null;

app.findGrepPreferences.findWhat = "~N";

var

     FindGrep=app.activeDocument.findGrep(),

     len = FindGrep.length,

     item, pageNo, calcNo, rightSide,

     mDiff = 460;          // edit this value according to needs

     while (len-->0) {

          item = FindGrep[len];

          pageNo = item.parentTextFrames[0].parentPage.name;

          calcNo = parseInt(pageNo) + mDiff;

          item.paragraphs[0].contents = calcNo + "\t" + pageNo;

          rightSide = item.parentTextFrames[0].textFramePreferences.textColumnFixedWidth;

          with (item.paragraphs[0]) {

               tabStops.add({alignment: TabStopAlignment.RIGHT_ALIGN, position: rightSide});

               justification = Justification.LEFT_ALIGN;

               }

          }

which should work assuming textFrames with pageNumbers are overridden (accessible)

Jarek

Participating Frequently
October 25, 2013

Hi,

Sorry for the delay in responding. But your script did just what I wanted.

Thank you so much.

Regards