1

I have a indesign document with several images. I want to update these images with Adobe Indesign Scripting. The following code works.

var file =  new File ('/MyDisk/image01.png');
app.activeDocument.links.item(1).relink (file);
var file =  new File ('/MyDisk/image02.png');
app.activeDocument.links.item(2).relink (file);

But you have to know the index of the link you want to change. If you're adding/deleting images on the page, this numbering can change. So I rather use the name of the pageItem itself. But I don't know how to do this.

With textItems, it is easy to refer to a object's name, but to change an image link by referring his name seems not possible. example:

app.activeDocument.textFrames.item('text frame').contents= 'changed content';
1

You can certainly use the name to target a collection's item:

var link = app.activeDocument.links.itemByName("myLink.jpg");
//Get sure the reference exists before any further action
if ( link.isValid ) link.relink ( … )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.