2 Replies Latest reply on May 31, 2013 2:19 AM by Muthuraj Durairaj

    Find and change hyperlinks applied on frames

    Muthuraj Durairaj Level 1

      Hi All,

       

      I found this solution in the forum, thanks to Ole (http://forums.adobe.com/message/1976301#1976301) for finding and replacing hyperlinks. It is working fine. My need is little different than this. The hyperlink change should happen only on hyperlinks added to graphicframes on last page of the document. I tried to add this  "&& myDestinationURL.source instanceof HyperlinkPageItemSource" in the if conditionbut not working.

       

      Please help me on this.

       

       

       

      var myDestinationURL;
      var myDocument = app.activeDocument;
      var myLastPage = myDocument.pages[-1]
      var findWhat = "www.google.com";
      var changeTo = "www.adobe.com";
      
      
      if(myDocument.hyperlinkURLDestinations.length > 0){
          for(var myCounter = myDocument.hyperlinkURLDestinations.length -1; myCounter >=0; myCounter--){
            myDestinationURL = myDocument.hyperlinkURLDestinations.item(myCounter).destinationURL;
            if(myDestinationURL.search(findWhat) != -1){ //  && myDestinationURL.source instanceof HyperlinkPageItemSource
             myDocument.hyperlinkURLDestinations.item(myCounter).destinationURL = myDestinationURL.replace(findWhat, changeTo);
            }
          }
      }
      
      

       

      Regards,

      Muthuraj. D

        • 1. Re: Find and change hyperlinks applied on frames
          Laubender Adobe Community Professional & MVP

          @Muthuraj – see:

          http://jongware.mit.edu/idcsjs5.5/pc_HyperlinkURLDestination.html

           

          There is no property "source". The "destinationURL" of "HyperlinkURLDestination" is simply a string.

           

           

          However, through a "Hyperlink" you can get the source.

           

          So, I fear, you have to loop all Hyperlinks of the document and sort out the right objects on the last page.

           

          For a specific Hyperlink object, that has a source of type "sourcePageItem" you can check for it's specific page as an index number in the page range from 0 to n.

           

          (Example of a document, that contains only one Hyperlink with a sourcePageItem as source):

           

          app.documents[0].hyperlinks[0].source.sourcePageItem.parentPage.documentOffset;
          

           

          The documentOffset value of the last page of your document can be written as:

           

          myDocument.pages.length-1;
          

           

          So you can sort out the right Hyperlinks for the last page and change the destination URL and (if you like) the name of the destination to fit your needs:

           

          app.documents[0].hyperlinks[0].destination.name;
          app.documents[0].hyperlinks[0].destination.destinationURL;
          

           

           

          Uwe

          1 person found this helpful
          • 2. Re: Find and change hyperlinks applied on frames
            Muthuraj Durairaj Level 1

            Hi Uwe,

             

            Sorry for the late reply, I was away for a while.

             

            Thanks for your quick reply. I will try this and let you know.

             

            Thanks.

             

            Regards,

            Muthuraj. D