Skip to main content
Bateson Publishing
Participating Frequently
December 3, 2018
Answered

Getting a script to search and save URL tags to text fields

  • December 3, 2018
  • 4 replies
  • 1293 views

My client is wanting to supply a library of URLs which should link to specific text labels in InDesign, with a script to assign the URL links to the text labels.

Eg. Whenever the script encounters a text label like ‘SA1757’ in InDesign text, it assigns a corresponding URL such as 'www.pharmac.govt.nz/latest/SA1757.pdf’ to it.

The process needs to be driven by a script in order to automate the process as there are quite a few of these text labels.

The end goal is to be able to generate URLs from these text labels automatically in a PDF file.

Would anyone know how to go about achieving this?

I'm guessing my client would supply some kind of data file (xml?) which assigns specific URLs to specific text fields, which I would then need to instruct InDesign how to process.

This topic has been closed for replies.
Correct answer Stephen Marsh

The process needs to be driven by a script in order to automate the process as there are quite a few of these text labels.

Have you searched for scripts to do what you want?

Do you mean that there are many variable “one off”  links in a spreadsheet or database, or that a small/limited list of links is repeated more than once in a long document?

Does the label text stay the same as it originally was with the hyperlink applied, or should the label text be changed to match the hyperlink?

Depending on the answers, native features could accomplish this without scripting, however scripting would make this so much easier.

EDIT: After some searching, the following script automates what I was suggesting is possible via native features (find/replace…Convert URL’s to hyperlinks…find/replace):

https://www.rorohiko.com/wordpress/use-indesign-find-and-replace-to-assign-hyperlinks-to-text/

Read the documentation carefully as the script must be configured to work with your required URL’s and links… However if you have a spreadsheet of the label and the matching link, then you would probably want a script that worked with such input.

4 replies

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
December 9, 2018

The process needs to be driven by a script in order to automate the process as there are quite a few of these text labels.

Have you searched for scripts to do what you want?

Do you mean that there are many variable “one off”  links in a spreadsheet or database, or that a small/limited list of links is repeated more than once in a long document?

Does the label text stay the same as it originally was with the hyperlink applied, or should the label text be changed to match the hyperlink?

Depending on the answers, native features could accomplish this without scripting, however scripting would make this so much easier.

EDIT: After some searching, the following script automates what I was suggesting is possible via native features (find/replace…Convert URL’s to hyperlinks…find/replace):

https://www.rorohiko.com/wordpress/use-indesign-find-and-replace-to-assign-hyperlinks-to-text/

Read the documentation carefully as the script must be configured to work with your required URL’s and links… However if you have a spreadsheet of the label and the matching link, then you would probably want a script that worked with such input.

Bateson Publishing
Participating Frequently
December 10, 2018

Many thanks for this: it looks bang on the money! I'll forward this to my client and we will hopefully be implementing this in the new year.

Have a great Christmas!!

Inspiring
December 8, 2018

HI,

Yes, if the root part of the URL  ('www.pharmac.govt.nz/latest/" changes then you would need some way to point the last portion of the URL to the text (I would suggest a spreadsheet. Unless the document is structured for XML, an xml file would be of no advantage.

S. Hopkins

Srishti_Bali
Legend
December 6, 2018

Moved to InDesign Scripting

FRIdNGE
December 3, 2018

Hi,

I did something that seems to me a little more complicated for a client.

You could contact me in private if no one helps you here! …

Best,

Michel, for FRIdNGE