4 Replies Latest reply on Jun 12, 2009 1:55 AM by Loic.Aigon

    JS CS3 : Hyperlinks.add(y,z) always recreates the same object :-(

    Loic.Aigon Adobe Community Professional

      Hi,

      I am trying to create hyperlinks from an index. The command works fine except that doc.hyperlinks.add(source,destination) always rewrites the former one. They don't stack and I need them to do this way.

      Could you help ?

       

      I write this function :

       

      function hyperlien(src,dest)
      {
          app.findTextPreferences.findWhat=src.contents;
          //var txtsrc = doc.hyperlinkTextSources.add(src);
          var txtsrc = doc.hyperlinkTextSources.add(doc.pageItems.item("index").findText()[0]);
          var pgdest = doc.hyperlinkPageDestinations.add();
          pgdest.destinationPage = dest;
          with(doc.hyperlinks.add (txtsrc,pgdest))
          {
              name = src.contents;
              visible = false;
          }
          app.select(NothingEnum.nothing, undefined);
      }

       

      and calls it this way :

      hyperlien(app.selection[0],myPage);

      according app.selection[0] is text, myPage is defined on top as:

      var sel=app.selection[0];
      var myFrame = app.selection[0].parentTextFrames[0];
      var myPage = myFrame.parent;

       

      the text is on a page but I try to apply the hyperlinks to the same text in the index. Hence I set my source as doc.pageItems.item("index").findText()[0]

       

      Hope you can help.

      Thanks Loic

        • 1. Re: JS CS3 : Hyperlinks.add(y,z) always recreates the same object :-(
          Harbs. Level 6

          Each hyperlink source can only be used once. That's how they work...

           

          Shared hyperlink destinations can be used as many times as you need, 

          but you can only create them once...

           

          Also, you can't name two of any aspects of hyperlinks the same name. 

          (I.e. You can't have two hyperlink destinations with the same name.)

           

          Harbs

          • 2. Re: JS CS3 : Hyperlinks.add(y,z) always recreates the same object :-(
            Loic.Aigon Adobe Community Professional

            Hi Harbs,

             

            Thanks a lot for answering.

             

            The fact is I change my selection all the time and then relaunch the script. It means that app.selection[0] should be always a different text source.

             

            I mean :

            considering this text :

            scin hent vullaore consed magna faciliquam zzrit la consenit lorem dio od magna accumsandre feu feuguerostio endre dolestrud dolesen issequi ssissisi.
            Utpat. Lorperit atie dionullute modignim dunt in exer

             

            I select vullaore then execute the script. I want it to hyperlink vullaor.

            Then once it's done, I select lorem and launch the script once again. So I expect this time the script takes lorem as source.

            Etc.

             

            If I use dummy datas such as hyperlien(app.selection[0], pg[0]) in a other script, it runs well (hyperlinks are stacked). But when I intend to use it in my global script with the real inputs, hyperlinks don't stack anymore.


            It's like something were persistent after the script :-(

             

            Hope to find the trick.

            Loic

            • 3. Re: JS CS3 : Hyperlinks.add(y,z) always recreates the same object :-(
              Harbs. Level 6

              I'm not sure I understand what you mean by "stacked".

               

              Harbs

              • 4. Re: JS CS3 : Hyperlinks.add(y,z) always recreates the same object :-(
                Loic.Aigon Adobe Community Professional

                Hi Harbs,

                Once again, thanks for your care on my topic.

                 

                Sorry for "stacked", my frenglish stroke back ;-)

                I mean that the standard behaviour of adding hyperlinks is like that in the hyperlinks palette :

                h1

                h2

                h3

                ...

                but in my script, the last hyperlink in the palette isalways replaced by the new one. I don't have a case like I describer but this in the palette :

                h1 is replaced by h2 which is replaced by h3, etc.

                So at the end I have only one Hyperlinks when I want 3 of them. As I said, I launched the script 3 times and expected to get 3 different hyperlinks but in fact, I get always the same replaced hyperlink.

                I place screenshots asap.

                 

                Thanks in advance.

                Loic

                 

                here are the screenshots

                h1.jpg is a capture of the screen after I launched the script at first. I get an hyperlink, that's ok.

                h1p.jpg are the h1 properties.

                h2.jpg is the capture of the palette after I launched the script the second time. The second hyperlinks replaced the first one.

                h2p.jpg are the h2 properties.

                 

                H1.jpg

                h1.jpg

                 

                h1p.jpg

                h1p.jpg

                h2.jpg

                h2.jpg

                h2p.jpg

                h2p.jpg

                 

                Hope it helps understanding the problem.

                Loic