Copy link to clipboard
Copied
There are a lot of illustrations in word, and it is difficult to find the position if they are to be included in InDesign.
Is there a way to directly convert some specific text in word into the path of the picture and insert it?
For example, there is a text like this:
-------------------------------------------------- --------------------------------------------------
In the United States, which is mired in multiple crises such as the new crown epidemic, economic recession, and racial issues, political polarization and social division have worsened during the election year, with frequent demonstrations, protests, conflicts, and riots.
@ D:\Mybook\abc\001. election.PSD@@
Election day on November 3 is imminent, and general election-related disputes such as mail voting may add another "fuse." American scholar Francis Fukuyama recently wrote an article worrying that "the United States may be experiencing a major crisis related to the election itself."
-------------------------------------------------- --------------------------------------------------
Can the picture pointed to by @ D:\Mybook\abc\001. election.PSD@ be inserted into this position automatically?
If it can be realized, multi-picture typesetting would be too much trouble...
Try this code sample:
//////////////////////////////////////////////////////////////////////////////////////////////////////
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.findWhat = "(?<=@)([^@]+)(?=@)";
var allFound = app.documents[0].findGrep();
for(var i = 0; i < allFound.length; i){
var allContent = allFound[i].texts[0].contents;
var filePath = File(allContent.toString().replace(/[\s]+/g,'').replace(/\\/g,'/'))
...
Copy link to clipboard
Copied
Perhaps with scripting (but I'm not a script writer). Definitely it's not built into InDesign's native abilities.
Copy link to clipboard
Copied
Hi,
it seems that a script originally written by Peter Kahrel and adapted by Kasyan Servetsky could do what you want:
Place inline images
Script for InDesign: tested in CC 2015.4
This script It finds text between two @ characters – e.g. @Deleted User.tif@ – and replaces it with the image that has the same name. The original script was written by Peter Kahrel. I found it somewhere on the Adobe scripting forum and reworked it to my liking.
http://kasyan.ho.ua/indesign/image/place_inline_images.html
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Where is the picture?
It should include the image path.
Because the pictures don't have to be in the links folder. At the beginning, the pictures are classified by customers, which should be followed. Finally, it will be collected under links
And the image should also apply the object style, for example, "myimg" object style
Copy link to clipboard
Copied
Try this code sample:
//////////////////////////////////////////////////////////////////////////////////////////////////////
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.findWhat = "(?<=@)([^@]+)(?=@)";
var allFound = app.documents[0].findGrep();
for(var i = 0; i < allFound.length; i){
var allContent = allFound[i].texts[0].contents;
var filePath = File(allContent.toString().replace(/[\s]+/g,'').replace(/\\/g,'/'));
if(filePath.exists){
if(allFound[i].insertionPoints[0].parent.characters[allFound[i].texts[0].characters[-1].index+1].contents == "@"){
allFound[i].insertionPoints[0].parent.characters[allFound[i].texts[0].characters[-1].index+1].contents = "";
app.documents[0].recompose();
}
allFound[i].texts[0].contents = "";
allFound[i].texts[0].insertionPoints[0].place(filePath);
if(allFound[i].insertionPoints[0].parent.characters[allFound[i].texts[0].characters[0].index-1].contents == "@"){
allFound[i].insertionPoints[0].parent.characters[allFound[i].texts[0].characters[0].index-1].contents = "";
app.documents[0].recompose();
}
}
else{
i++;
}
app.documents[0].recompose();
var allFound = app.documents[0].findGrep();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
Best
Sunil
Copy link to clipboard
Copied
Where is the picture?
It should include the image path.(For example, D: \mybook-1\originalfile\ pic01\001.tif)
Because the pictures don't have to be in the links folder. At the beginning, the pictures are classified by customers, which should be followed. Finally, it will be collected under links
And the image should also apply the object style, for example, "myimg" object style
Copy link to clipboard
Copied
This script can import a picture, but the picture is too large and the text box is stretched too wide, so the picture cannot be displayed.
Is it possible to customize an object style for imported pictures, such as: "mypic"