Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Re: Doubt hyperlink Page Destination

$
0
0

@Peter – hm, I think myPagedestination[j].pages[0] cannot work, because hyperlinkPageDestinations have no page property…

 

There is a destinationPage property for that purpose.

 

And if we remove all hyperlinkPageDestinations whose destination pages have no page items, wouldn't that leave the corresponding hyperlinks intact? With a destination property that is null?

 

If we'd like to remove also ALL hyperlinks with destination:null, we could use this code:

 

var d=app.documents[0]; 
$.writeln("Hyperlink length BEFORE: "+d.hyperlinks.length); //Remove all hyperlinkPageDestinations, if there are no pageItems on the page: for(var n=d.hyperlinkPageDestinations.length-1;n>=0;n--){    if(d.hyperlinkPageDestinations[n].destinationPage.allPageItems.length === 0){        d.hyperlinkPageDestinations[n].remove();        };    }//So that we removed the hyperlinkPageDestinations, the corresponding hyperlinks are still there.//Should they also be removed? //Generally: schould ALL hyperlinks be removed without destinations?//(Not ONLY the ones we cared about as we removed their destinations in the loop above, but really ALL without destinations) //If so, we can run this loop: for(var n=d.hyperlinks.length-1;n>=0;n--){    if(d.hyperlinks[n].destination === null){        d.hyperlinks[n].remove();        };    }; 
$.writeln("Hyperlink length AFTER: "+d.hyperlinks.length);

 

 

But this is debatable…

 

To get this really right* we should:

 

1. Collect all the documentOffset values for all pages without any page items
2. Loop through all the hyperlinks of the document in reverse order
3. Check, if the destination is of type "HyperlinkPageDestination" with something like that:

if(myHyperlink.destination.constructor.name === "HyperlinkPageDestination")

If that is true, check, if the destinationPage.documentOffset is in the array with the empty pages and if yes, remove the hyperlink.

 

* only if my assumption is right, that not only the found hyperlinkPageDestination should be removed, but also all corresponding hyperlinks.

 

Uwe


Viewing all articles
Browse latest Browse all 37788

Trending Articles