4 Replies Latest reply on Aug 19, 2014 10:10 PM by bjlongo

    How to rename bookmarks

    bjlongo

      I'm simply trying to rename a bookmark via javascript, and keep running into the notallowederror: security settings... Previously, when I ran into this problem, I could avoid it by certifying the document, which would allow the javascript to run as privileged.  However, renaming bookmarks is apparently quite a sinister activity, and needs extra security??  I made folder level scripts:

      var renameBook = app.trustedFunction(

        function(thisPage)

        {

          app.beginPriv();

          var books = this.bookmarkRoot.children;

          for (var i = 0; i < books.length; i++) {

            var vNotes;

            if (books[i].name == "Visit Notes") {

              vNotes = books[i].children;

              for (var j = 0; j < vNotes.length; j++) {

                if (vNotes[j].name == thisPage)

                  vNotes[j].name = vNotes[j].name + "-signed: " + new Date();

              }

            }

          }

          app.endPriv();

        }

      );

      and call that from my document-level script, but I get the same problem...  what am I doing wrong?

        • 1. Re: How to rename bookmarks
          try67 MVP & Adobe Community Professional

          This code doesn't require special permissions and you don't need to place it in a trusted context or anything like that. However, you won't be able to use it in Reader since it can't change the names of bookmarks. Is that what you're trying to do?
          If not, then please post the exact error message you're getting.

          • 2. Re: How to rename bookmarks
            bjlongo Level 1

            Thanks for the response.  No, I'm not trying to use it in Reader.  I'm working exclusively in Acrobat.  But since you brought it up, what you're saying is that even if I got this working in Acrobat and saved it as Reader Enhanced, it wouldn't be able to change the name of the bookmark using Reader? 

            When I use either the trusted function (in the folder level script) or try to change the bookmark name directly in my local scripts, I get:

            NotAllowedError: Security settings prevent access to this property or method.

            Preferences:

            Javascript:

            enable acrobat javascript "On"

            enable menu items javascript execution privileges "On"

            enable global object security policy "Off" (although I've tried it both ways)

             

            Security (Enhanced):

            enable enhanced security "Off" (tried it both ways)

             

            I noticed that I could make it work correctly through a menuitem, but that I want this to be affected when I sign a digital signature.  Perhaps there's a workaround on this using the menuitem (perhaps make a hidden menuitem, and execute that? I'm not quite sure how to make that work, but maybe that's a possibility).  I'd prefer to make this work the way it seems like it's supposed to...  Thanks again.

            • 3. Re: How to rename bookmarks
              try67 MVP & Adobe Community Professional

              Please post the FULL error message, including line number.

               

              And no, it will never work in Reader, no matter what rights you apply to the file.

              • 4. Re: How to rename bookmarks
                bjlongo Level 1

                If it won't work at all, then I don't really believe that I can go any further with that.  I'll go a different route.  Thanks for your help.