Script to create URL-s from text frames

Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Script to create URL-s from text frames

Viewing 1 reply thread
  • Author
    Posts
    • #110983

      Hey everyone!

      I was wondering if there was a script around that converts linked textboxes with URL-s in them into clickable elements.
      See the example here: https://www.dropbox.com/s/9vchfnpr7xy08ru/example.jpg?dl=0 The idea behind it is having sort of an overlay of shop links above boxes in a product catalogue.

      Any help would be greatly appreciated!

    • #111149

      That is specific enough to not exist anywhere. No sweat, though. Fortunately it is small enough and quick to write.

      Select any of your threaded frames, and run this script. Be warned that it exactly does what it says on the tin: it blandly and blindly converts the text inside each frame to a single hyperlink by pasting “https://” in front of it and then connects that one link to its parent text frame. I have no idea what happens if there already is a link connected to the frame, or if you (accidentally or otherwise) have more text than a single link inside a text frame. Feel free to experiment, though :)

      
      tc = app.selection[0].parentStory.textContainers;
      for (f=0; f<tc.length; f++)
      {
          src = app.activeDocument.hyperlinkPageItemSources.add(tc[f]);
          dest = app.activeDocument.hyperlinkURLDestinations.add('https://'+tc[f].contents.replace(/\s+$/, ''));
          app.activeDocument.hyperlinks.add(src, dest);
      }
      • #111180

        This is brilliant!
        Thank you so much, its exactly what i needed in a form that is dead simple to apply to my workflow.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.
>