3 Replies Latest reply on Jul 22, 2009 2:36 AM by [Jongware]

    list of hyperlinks

    jay fresno Level 2

      Is it possible to create a list of all the hyperlinks in an InDesign document? I don't see this feature in the Hyperlinks panel, but perhaps it can be scripted.


      There is an Acrobat script to do just that (below); maybe a script in InDesign would be similar?


      var numLinks=0;
      for ( var p = 0; p < this.numPages; p++)
      var b = this.getPageBox("Crop", p);
      var l = this.getLinks(p, b);
      numLinks += l.length;
      console.println("Number of Links in Document is " + numLinks);

        • 1. Re: list of hyperlinks
          Thomas B. Nielsen Level 3

          Selecting a textframe and running the below code in cs3, will put a list of all URL hyperlinks in the selected textframe.


          var myDocument = app.activeDocument;
          if(myDocument.selection.length == 1) {
              if (myDocument.selection[0].constructor.name == "TextFrame") {
                  myDocument.selection[0].contents = setHyperlinksAsContent();


          function setHyperlinksAsContent() {
              var myHyperlinks = myDocument.hyperlinkURLDestinations;
              var myString = "";
              for (i = 0 ; i < myHyperlinks.length; i++) {
                  var myLink = myHyperlinks[i];
                  myString += myLink.destinationURL + "\n";
              return myString;

          1 person found this helpful
          • 2. Re: list of hyperlinks
            jay fresno Level 2


            Thank you for your script. It could be helpful. What I was actually thinking was a script that would list all hyperlinks, including URLs, page links, and so forth, and put the list in a separate text frame or separate file. Your script is definitely a step in the right direction. Thank you.

            • 3. Re: list of hyperlinks
              [Jongware] Most Valuable Participant

              To add a new frame, use this:


              frame = app.layoutWindows[0].activePage.textFrames.add({geometricBounds:["10mm","12mm","200mm","1 20mm"]});


              (note the coordinate system: [y1, x1, y2, x2], in your current user space relative to the rulers; adjust at will

              and next, fill it using Thomas' function:


              frame.contents = setHyperlinksAsContent();


              To write to a file:


              var myDocument = app.activeDocument;
              var list = setHyperlinksAsContent();
              outFile = new File(decodeURI($.getenv("TEMP")) + "/links.txt");




              Testing this out, I found something unexpected: the list of hyperlinks showed the ones I made, plus one that (apparently) was imported with the document! It makes some sense, because in the interface you can create hyperlinks and then have some text point to them.


              So you should be prepared to see hyperlinks that do not appear linked in your text (or ask Thomas how to weed those out ).