3 Replies Latest reply on Nov 16, 2009 12:09 PM by [Jongware]

    How to get page no.

    Shonkyin Level 3

      Hi All,



      Please see my below code and suggest me:


      var myDoc =app.activeDocument;

      app.findTextPreferences = NothingEnum.nothing;

      app.changeTextPreferences = NothingEnum.nothing;

      app.findTextPreferences.appliedParagraphStyle = '00_folio';

      var folio_result = myDoc.findText()

      Now i want page number of each founded text
      with below code it will give me parent text frame page number and some cased parent text frame on another page.
      var page_num = folio_result[a].parentTextFrames[0].parent.name
      Please suggest me code for current page number of founded text.

        • 2. Re: How to get page no.
          Shonkyin Level 3

          Dear Thomas,


          In above post ill get parent Text frame page no. not current.


          I want current Text frame page no.



          • 3. Re: How to get page no.
            [Jongware] Most Valuable Participant

            That's not a problem (if I understand correctly).


            var page_num = folio_result[a].parentTextFrames[0].parent.name;


            The array folio_result will only hold the actual text you were searching. Likewise, its parentTextFrames[0] will be the frame that the exact phrase is found in. The only borderline case is when your found text spans two (or more) frames. To check if that happens, you will have to check the length of the parentTextFrames array (i.e., 1 for a single page, 2 or more if your text spans multiple frames). Note that it's also possible that a text spans two separate frames but only appears on one single page (for example, if you used manually constructed columns and the phrase goes from the left column to the right on the same page).

            If a single found phrase spans more pages, you will have to decide whether you want to know its starting page, its ending page, or something inbetween -- or perhaps a range, such as "15-16".