Automatically create hyperlinks with a script
Copy link to clipboard
Copied
Hello
I have created a catalog in indesign with about 8000 Articles in it. The Cataloge looks similar to this:
Article # | Name | Price |
---|---|---|
8762903 | Article 1 | 18 $ |
8456901 | Article 2 | 7 $ |
Later I want to export the whole catalog as a PDF Document and want that my customers can click on every article number in the PDF Document and are getting redirected automatically to my online shop. The Shop URL looks like this: https://www.testshop.com/*Article​Number*
Can someone please help me creating a Script, which automatically searches in the indesign Document for all Article Numbers (Always starting with the number 8 and then have 6 more digits) and add a hyperlink to the correct URL (https://www.testshop.com/*ArticleNumber*)?
I really hope someone could help me, as I am trying to solve this problem for days.
Thank you so much!
Copy link to clipboard
Copied
Hi,
I exactly wrote such a script for a client several months ago.
If Interested, you could contact me! …
Best,
Michel, for FRIdNGE
Copy link to clipboard
Copied
If you are using OSX this AppleScript works on the sample text you posted. The URLs are formattted like this: https://www.testshop.com/*8762903
tell application "Adobe InDesign CC 2018"
activate
tell active document
-- finds all 7 digit numbers
set fg to my GrepSearch("\\d{7}")
--hyperlink each number.
repeat with x in fg
set t to contents of object reference of x
set hs to make hyperlink text source with properties {source text:x}
set hl to make hyperlink URL destination with properties {destination URL:"https://www.testshop.com/*" & t}
set h to make hyperlink with properties {source:hs, destination:hl}
end repeat
end tell
end tell
on GrepSearch(f)
tell application "Adobe InDesign CC 2018"
set find grep preferences to nothing
set find what of find grep preferences to f
return find grep
end tell
end GrepSearch
Copy link to clipboard
Copied
Hi Rob,
Use \b8\d{6}\b Better!
My Script [Javascript => Mac & Windows] uses the F/R window to test the code and, when you launch the script, the 2 codes are directly pasted in the UI as last control:
Just play "OK"! That's all!
The script includes a progress bar [useful with thousands of hyperlinks to be created], a final counter [just to say: "Wow! … " ] and a global undo.
Note: if you add more product references, just run again the script: no interference with the job already done. The script just creates other new hyperlinks.
Best,
Michel
Copy link to clipboard
Copied
Kris from Rorohiko wrote a great javascript for someone at CreativePro Week this past June. It uses GREP to find the string, then plops the found text into a URL. You'll need to configure the GREP and the hyperlink destination (he has instructions in the script and on his blog).
https://www.rorohiko.com/wordpress/use-indesign-find-and-replace-to-assign-hyperlinks-to-text/
EDIT: I'm not sure it works in tables, however. I can't seem to get it to work within a table. But I'll keep trying. I've used it for other searches just fine.
Copy link to clipboard
Copied
Mine works everywhere, even in the kitchen! …
Best,
Michel
Copy link to clipboard
Copied
royb74794940​
Thread goes to InDesign scripting forum.
Copy link to clipboard
Copied
I have created a catalogue in inDesign with thousand of items in it, starting form an Excel file. I create a QR code using data merge, but I want to export it as a PDF (interactive) and want that customers can click on the QR code (or on the title) and be redirected automatically to my URL (same one that has generated the QR code obviously). Is it possible?
Copy link to clipboard
Copied
Hi _ross_,
what other interactive features should be in your catalog PDF ?
Should it work with unknown reader software on tablets and mobile devices?
Or can you make sure that your audience is using Adobe Reader on Windows or OS X only?
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
No mobile device needed, I think that desktop use is enough. Dumb down: if you print printing a page you can access to the URL using the QR code, if you take a look at it on your PC, you can click on a button/text/QR and be redirect to the same URL.
Why can data merge generate a QR code but not embed the same URL as an hyperlink?

