2 Replies Latest reply on Dec 30, 2012 8:28 PM by Sudha K

    Page number of linked textframe in indesign document

    Sudha K Level 1

      Hi,

       

       

        My indesign document has linked pages 1 - 10 (ie., linked textframes).  I want to take page number of selected text from 5th page., which textframe is linked textframe of 1st page.  When i use the following code for findpage, its returning the page no 1 instead of 5. 

       

      Kindly reply for me...

       

      var page = findPage(app.selection[0]);    // selection is a word/para

       

      function findPage(theObj)

      {

          var thePage = theObj;

          if (thePage.hasOwnProperty("baseline"))

          {

              thePage = thePage.parentTextFrames[0];

          }

          while (thePage.constructor.name != "Page")

          {

              var whatIsIt = thePage.constructor.name;

       

              switch (whatIsIt)

              {

                  case "Story" :

                      thePage = thePage.textFrames[-1].parent;

                      break;

                  case  "Character" :

                      thePage = thePage.parentTextFrames[0];

                      break;

                  case "Cell" :

                      if ( thePage.insertionPoints[0].parentTextFrames[0] == null)

                      {

                          // contents of cell is overset

                          thePage = tryHarderForCell(thePage);

                          if (thePage == null) return null;

                          break;

                      }

                      else

                      {

                          thePage = thePage.insertionPoints[0].parentTextFrames[0];

                          break;

                      }

                  case "Application" :

                  return null;

              }

              thePage = thePage.parent;

          }

          return thePage ;

      }