Highlighted

Target the Source Hyperlink Destination Document of an Hyperlinks

Advocate ,
Sep 16, 2020

Copy link to clipboard

Copied

I have a bunch of InDesign Doc, with Hyperlink with source are an anchor text in others InDesign document. If I rename the source document, all the hyperlink will be broken.

I have a script that can perform a GREP change/replace but it for URL Destination.

 

How can I edit this part to change it to the Document Destination name instead.

 

This part need to be edited.

var dests = app.documents[0].hyperlinkURLDestinations.everyItem().getElements();
	for(var i=0;i<dests.length;i++){
		dests[i].destinationURL = dests[i].destinationURL.replace(grepForFind,grepForReplace);

 

Adobe Community Professional
Correct answer by Peter Kahrel | Adobe Community Professional

Hi Jean-Claude. This is a murky area of hyperlinks, and unfortunately what you're after -- change the name of the document that contains the targeted text anchor -- isn't possible. When the destination is an external page, you can simply set the target document's path using the documentPath property. But for external text anchors that property is not available.

 

Given a document with one hyperlink whose destination is a text anchor in another document,

app.documents[0].hyperlinks[0].destination

returns the external text anchor, and 

app.documents[0].hyperlinks[0].destination.parent

 returns the external document. There's no way you can change that.

 

The script's behaviour, when you call 'app.documents[0].hyperlinks[0].destination', is an error:

Error: Hyperlink destination document not found. Please verify the document's location in the Hyperlinks panel before choosing this hyperlink.

 

which of course is pretty dumb, but there you are.

TOPICS
Scripting

Views

81

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Target the Source Hyperlink Destination Document of an Hyperlinks

Advocate ,
Sep 16, 2020

Copy link to clipboard

Copied

I have a bunch of InDesign Doc, with Hyperlink with source are an anchor text in others InDesign document. If I rename the source document, all the hyperlink will be broken.

I have a script that can perform a GREP change/replace but it for URL Destination.

 

How can I edit this part to change it to the Document Destination name instead.

 

This part need to be edited.

var dests = app.documents[0].hyperlinkURLDestinations.everyItem().getElements();
	for(var i=0;i<dests.length;i++){
		dests[i].destinationURL = dests[i].destinationURL.replace(grepForFind,grepForReplace);

 

Adobe Community Professional
Correct answer by Peter Kahrel | Adobe Community Professional

Hi Jean-Claude. This is a murky area of hyperlinks, and unfortunately what you're after -- change the name of the document that contains the targeted text anchor -- isn't possible. When the destination is an external page, you can simply set the target document's path using the documentPath property. But for external text anchors that property is not available.

 

Given a document with one hyperlink whose destination is a text anchor in another document,

app.documents[0].hyperlinks[0].destination

returns the external text anchor, and 

app.documents[0].hyperlinks[0].destination.parent

 returns the external document. There's no way you can change that.

 

The script's behaviour, when you call 'app.documents[0].hyperlinks[0].destination', is an error:

Error: Hyperlink destination document not found. Please verify the document's location in the Hyperlinks panel before choosing this hyperlink.

 

which of course is pretty dumb, but there you are.

TOPICS
Scripting

Views

82

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 16, 2020 0
Adobe Community Professional ,
Oct 10, 2020

Copy link to clipboard

Copied

If you share some of those destination URL, or share some more information.

Then it is easy to help you.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 10, 2020 0
Advocate ,
Oct 10, 2020

Copy link to clipboard

Copied

Hi,
The issue here is with hyperlinks which targer are an anchor text inside differents document. If you change the name of theses InDesign document, the hyperlinks are all broken. But internally, they are still there but not visually accessible to the UI. So It would be usefull to rename the destination indesign document internally with a script.

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 10, 2020 0
Adobe Community Professional ,
Oct 11, 2020

Copy link to clipboard

Copied

Hi Jean-Claude. This is a murky area of hyperlinks, and unfortunately what you're after -- change the name of the document that contains the targeted text anchor -- isn't possible. When the destination is an external page, you can simply set the target document's path using the documentPath property. But for external text anchors that property is not available.

 

Given a document with one hyperlink whose destination is a text anchor in another document,

app.documents[0].hyperlinks[0].destination

returns the external text anchor, and 

app.documents[0].hyperlinks[0].destination.parent

 returns the external document. There's no way you can change that.

 

The script's behaviour, when you call 'app.documents[0].hyperlinks[0].destination', is an error:

Error: Hyperlink destination document not found. Please verify the document's location in the Hyperlinks panel before choosing this hyperlink.

 

which of course is pretty dumb, but there you are.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 11, 2020 0
Advocate ,
Oct 11, 2020

Copy link to clipboard

Copied

Thanks for replying...
Too bad we can’t access this information (that are still in the document) when the document is missing or rename.

Only workaround found so far is to do find/replace on .idml

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 11, 2020 0