Copy link to clipboard
Copied
Hey everyone!
I'm wondering are there any way to render a column of images from excel sheet to indesign using script?
because i managed to read the column but once i do this line of code downbelow, appers to me an alert message telling me this:
Error: Cannot create the link resource from the given URI.
doc.textFrames[counterFrame].place(tempArr2[k])
also, to make sure that the system reads the links proprly i've printed each uri in the specified textframe, and it works good! and i've extracted the uri from the terminal so i'm pretty sure it's valid.
doc.textFrames[counterFrame].contents= tempArr2[k]
so, the proplem rase when i use the place method. any one nows how can i slove it?
i'm using javascript.
Hi Brian,
We can place image into a textframe it is automatically converted into rectangle, so that should not be an issue.
salshaw749 Can you try the following
if(doc.textFrames[counterFrame].isValid == true)
doc.textFrames[counterFrame].place(File(tempArr2[k]))
else
alert("The frame is invalid")
-Manan
Copy link to clipboard
Copied
You need to place an image into a Rectangle or other graphics frame. A text frame can't accept it.
var rect = doc.rectangles.add();
rect.place(temp2Arr[k]);
rect.fit();
Copy link to clipboard
Copied
Hey, thanks for replaying. I've changed as you said and still get the same alert.
Copy link to clipboard
Copied
Hi Brian,
We can place image into a textframe it is automatically converted into rectangle, so that should not be an issue.
salshaw749 Can you try the following
if(doc.textFrames[counterFrame].isValid == true)
doc.textFrames[counterFrame].place(File(tempArr2[k]))
else
alert("The frame is invalid")
-Manan
Copy link to clipboard
Copied
Thanks Manan! That's works!
I've tried to use rectangle insted for the purposes of the project. anyhow, I want to place more than one picture in the same rectangur but it only catch the last one in the array and ignore the others, do you know why? this is the code i'm using.
for(var k =0; k<=tempArr2.length-1;k++){
if(doc.rectangles[counterFrame].isValid == true){
doc.rectangles[counterFrame].place(File(tempArr2[k]))
doc.rectangles[counterFrame].fit(FitOptions.CONTENT_TO_FRAME)
doc.rectangles[counterFrame].select(SelectionOptions.ADD_TO)
}
else{
alert("The frame is invalid")
}
}
Copy link to clipboard
Copied
This is how InDesign works you can't host more than one image in a frame, so the behaviour is correct. You can try doing the same using UI and will see its not possible. So the option that you have is to create new frames for each image and size/position them as needed.
-Manan
Copy link to clipboard
Copied
Thanks Manan, for sharing the knowledge!