2 Replies Latest reply on Mar 9, 2011 2:01 AM by jeanmed

    page reference

    jeanmed

      Hello,

       

      I need for a bookmark creation to know the page number of the item :

       

      I find a caratere style position with :

      var bm_name= myResults[f].contents;

       

      how can i find the page reference or number ?

      var myPage = ????????????????????

       

       

      My full code :

       

      var myDocument = app.documents.item(0);
      app.findTextPreferences = app.changeTextPreferences = null;
      app.findTextPreferences.appliedCharacterStyle = "test";
      var myResults = app.activeDocument.findText();
      for (f = 0; f < myResults.length; f++)
      {
      var bm_name= myResults[f].contents;


      var myPage = ????????????????????
      var myBookmark = myDocument.bookmarks.add({destination:myPage, name:bm_name, label:bm_name});



      }

       

       

      Thanks

        • 1. Re: page reference
          csm_phil Level 4

          Hi Jeanmed,

           

          i have checked your js code and i get the page number, see below my modified your js code:

           

           

          var myDocument = app.documents.item(0);
          app.findTextPreferences = app.changeTextPreferences = null;
          app.findTextPreferences.appliedCharacterStyle = "test";
          var myResults = app.activeDocument.findText();
          for (f = 0; f < myResults.length; f++)
          {
          var bm_name= myResults[f].contents;
          var myPage = myResults[f].parentTextFrames[0].parent.name;
          //alert(myPage );
          var myBookmark = myDocument.bookmarks.add({destination:myPage, name:bm_name, label:bm_name});
          }

           

          regards

          CSM_PHIL

          • 2. Re: page reference
            jeanmed Level 1

            Hello

             

            Thanks for your help but it dont works !

             

            var myPage = myResults[f].parentTextFrames[0].parent.name;
            alert(myPage );   // returns nothing

             

            We have the same probleme we dont finded yet the method to find the page reference !

             

            Thanks