Copy link to clipboard
Copied
Is there a way to find and replace image path in a text or table with a linked images in InDesign.
I have a database with the products and the path to the barcodes image,
When copied into InDesing I then need the image paths to be replace with a linked images.
e.g. ./Barcode/9341215001038.png
Mail merge is not an option for versos reasons for this project.
Thanks for your reply, I feared it would not be trivail, as I coudnt find any scripts.
Idealy the text from the databse is place in a table witht the last column beeing the barcodes path, the images are to replace the text path and be place inside the cell, fitting within the cells width and/or height.
Copy link to clipboard
Copied
Short answer: yes, there is likely a way. Long answer: you would need a lot more details (how big should the images be, fitting options, other corner cases) before we could begin to help but it's not exactly a trivial task.
Copy link to clipboard
Copied
Thanks for your reply, I feared it would not be trivail, as I coudnt find any scripts.
Idealy the text from the databse is place in a table witht the last column beeing the barcodes path, the images are to replace the text path and be place inside the cell, fitting within the cells width and/or height.
Copy link to clipboard
Copied
Rudimentarily, with a textframe containing the table selected:
var table = app.selection[0].tables[0];
var rows = table.rows.everyItem().getElements();
var lastCell, lcContents;
for (var i = 0; i < rows.length; i++) {
lastCell = rows[i].cells[-1];
lcContents = lastCell.contents;
lastCell.contents = "";
lastCell.convertCellType(CellTypeEnum.GRAPHIC_TYPE_CELL);
lastCell.rectangles[0].place(File(lcContents));
}
Lots of pitfalls. Place won't work if cell is overset. This assumes the cell contains the complete path. Not sure if the cell dimensions would change in the conversion. Will require some finetuning.
Copy link to clipboard
Copied
thanks heaps,
It didnt work out of the box, but with a little finetuning I'm sure I can get it to work. you have showed me the way.
I admire how you managed to condence to code, its beautiful