Hi all,
Im just a newbie to InDesign Scripting and got a simple question.
I got some TextFrames with multiple imagepaths all seperated in lines in there and want to convert them to the actual images.
I can do this with the following JavaScript:
Placeholder = app.selection[0];
var imagepath = app.selection[0].contents;
Placeholder.place (File(imagepath), false);
The only problem I have here is that this just works with one path. If there are more paths included it won't work.
So I decided to seperate the TextFrame to one TextFrame for one path. This could be accomplished with the following script:
var myDocument = app.activeDocument;
app.selection[0].label = "MyTestLabel";
myParagraphs = app.selection[0];
var ii = 1; for (var one = 0; one <1; one++){ var gB1 = app.selection[0].geometricBounds[0]; var gB2 = app.selection[0].geometricBounds[2]; var gB3 = app.selection[0].geometricBounds[1]; var gB4 = app.selection[0].geometricBounds[3]; }for (var i = 0; i < 6; i++) { myParagraphs = app.selection[0].paragraphs[i].contents; var myTextframe = myDocument.textFrames.add(); gB1 = gB1+40; gB2 = gB2+40; myTextframe.geometricBounds = [gB1,gB3,gB2,gB4]; myTextframe.contents = myParagraphs; myTextframe.label = "Path"+ii; ii++;}
This script got some problems because I just merged it together from multiple sources and tried to modify it until it works. So I got some questions:
First I want to replace the parameter of the second for loop with a variable. I thought it is paragraphs.length but that doesn't work. This is important because the Paragraph length of each TextFrame is different.
Then you may noticed I assigned labels to each new created TextFrame. They are Path1, Path2.. etc.
How can I select objects like my TextFrames by label? I searched a lot about this question it seems that this functionality has changed since CS5 if I understood everything right.
I hope you can help me there, because then I can automatically seperate the paths and turn them into the actual images.
Maybe you guys know an easier way without selecting certain objects.
I would really appreciate your answers.
Thanks in advance!