ExtendScript keep hyperlink page after changing document path
Hello,
I'm trying to merge multiple Indesign documents and having problems with keeping the hyperlinks. The documents have external page hyperlinks and after merging I have to change the destination to the merged document. So I've created a little script that checks all hyperlinks and sets their documentPath to the current file. But the page from this hyperlink is lost after this. So I'm trying to save the page to a variable before changing the documentPath. But I can't set the destinationPageIndex with the variable. If I check the variable it has the right value, but setting it doesn't work, the hyperlink resets to page 1. If i just set destinationPageIndex = 20 for example it sets all links correctly. So it just ignores the page variable. It seems like a simple problem but I seem to miss something.
var doc = app.activeDocument;
var hyperlinks = doc.hyperlinks;
for (i = 0; i < doc.hyperlinks.length; i++){
var hyperlink = hyperlinks[i];
var destination = hyperlink.destination;
if (destination instanceof HyperlinkExternalPageDestination) {
var page = destination.destinationPageIndex;
destination.documentPath = doc.fullName.absoluteURI;
destination.destinationPageIndex = page;
//destination.destinationPageIndex = 20;
}
}
