1 Reply Latest reply on Nov 23, 2008 8:57 AM by Loic.Aigon

    URL from Character Style

      I am trying to figure out how to create a script of some kind (apple or java) that will search a document for any instance of a character style and turn that into a URL. If this has been posted before does anyone know where? I searched but can't find anything.

      Any help or guidance would be appreciated. I am using CS3 on MAC.

      Thanks
        • 1. Re: URL from Character Style
          Loic.Aigon Adobe Community Professional
          Hi,<br />//Assuming your character styles is called "web"<br />//In other cases, replace web by your own predefinite name<br /><br />var doc=app.activeDocument;<br />//Define find text preferences as text using character style called "web"<br /><br />app.findTextPreferences.appliedCharacterStyle=doc.characterStyles.item("web");<br /><br />//Find text occurences that match the preference<br /><br />var found = app.findText();<br /><br />//Add hyperlinks to the occurences<br /><br />for(i=0; i<found.length; i++)<br />{<br /><br />//Replace Yahoo.fr by your desired website<br />     <br />var dest=doc.hyperlinkURLDestinations.add("http://www.yahoo.fr");<br />     <br />var source = doc.hyperlinkTextSources.add(found[i]);<br />     <br />var dest=doc.hyperlinkURLDestinations.add("http://www.yahoo.fr");<br />     <br />doc.hyperlinks.add(source,dest, {visible:false, name:"yahoo.fr ("+(i+1)+")"});<br /><br />}<br />//If you want to export your doc as a interactive document, don't forget to set add hyperlinks to true or they won't be active in your pdf.<br />Loic