2 Replies Latest reply on Mar 8, 2011 11:17 PM by jeanmed

    bookmarks with javascript

    jeanmed Level 1

      Dear,

       

      I creat à script who search all the items who use a specified character style.

      It works, and know i need to creat for each item a bookmark.

       

      Can help for the javascript ?

       

      Dont know the methode ou function i chould use and how.

       

      Thanks

        • 1. Re: bookmarks with javascript
          Techi Panda Level 2

          Hi

           

          You can try this CS3 script

           

          var myDocument = app.documents.item(0);
          app.findTextPreferences = app.changeTextPreferences = null;
          app.findTextPreferences.appliedCharacterStyle = "BookMark";
          var myResults = app.activeDocument.findText();
          for (f = 0; f < myResults.length; f++)
          {
          var bm_name= myResults[f].contents;
          var found_frame_parent = myResults[f].parentTextFrames[0].parent;
          var found_page = found_frame_parent.name-1;
          var myHyperlink =  myDocument.hyperlinkPageDestinations.add(app.documents.item(0).pages[found_page], {name:bm_name});
          var myBookmark = myDocument.bookmarks.add({destination:myHyperlink, name:bm_name, label:bm_name});
          }

           

          thanks

           

          regards

          a r u l

          1 person found this helpful
          • 2. Re: bookmarks with javascript
            jeanmed Level 1

            Hello

             

            I am trying à script for creating bookmarks from a style charater search.

            The script works but the bookmarks created dont works well, when you click on a bookmark brom the bookmarks window. You are note redirected to the right bookmark.

             

            my 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 found_frame_parent = myResults[f].parentTextFrames[0].parent;
            var found_page = found_frame_parent.name-1;
            var myHyperlink =  myDocument.hyperlinkPageDestinations.add(app.documents.item(0).pages[ found_page], {name:bm_name});// here the hyperlink
            var myBookmark = myDocument.bookmarks.add({destination:myHyperlink, name:bm_name, label:bm_name});// here the bookmark creation
            }

             

            Thanks