Skip to main content
Participant
February 9, 2015
Question

Replace an image by another with a javascript in Indesign CS6

  • February 9, 2015
  • 1 reply
  • 1124 views

I am really desperate.  I have no idea where to start since I have no knowledge of javascript.  Can anyone please help?

I need a javascript that replaces 5 logo's in an active, multi-page, CS6 document.

In certain cases the logo's need to be replaced.

For example:

logo1.pdf  has to become logoA.pdf

logo2.pdf has to become logoB.pdf

logo3.pdf has to become logoC.pdf

logo4.pdf has to become logoD.pdf

logo5.pdf has to become logoE.pdf

All the logo's are in the same folder.  The original and the new logo's have the same dimensions /etc.

So it would be nice to select the logo's that need to be repaced and then run the javascript.

This topic has been closed for replies.

1 reply

Loic.Aigon
Legend
February 10, 2015
Ravindra_KCS
Inspiring
February 11, 2015
varmLinks = app.activeDocument.links.everyItem().getElements();
var  cLink, cFile; 
 
while ( cLink = mLinks.pop() )
    if(cLink.name =="logo1.pdf")
         cFile = File(cLink.path+"logoA.pdf"); 
 
      cLink.relink(cFile); 
 
Participant
February 11, 2015

I get a Javascript Error.

Error Number: 55

Object does not support the property of method 'path'

Line:7

Source: cFile = File(cLink.path+"logoA.pdf")