DataMerge icons/images inline into text frames
Add the ability to put file paths for icons/images with text in a cell, so that the images are merged inline with the text in a text frame. For example "Here is some text and here's an @icon.ai" would merge the icon.ai file into the text.
I know a lot of people who do work on card games using DataMerge, and this is the single most frequent request I get.
Currently the way we get around this is by merging text with placeholders like "[icon]", then copying the icon to the clipboard and doing a find and replace [icon] with the clipboard contents. This slightly defeats the purpose of DataMerge by adding several extra steps.
-
Max Seidman
commented
Well here we are 7 years later and I still want this and they still haven't added it, so here's my solution for everyone. I have created a script to handle this for you. Instructions are in the script:
/*====================================
HOW TO USE
1. Create an Indesign file called "Icon Library"
2. Paste or place all of your inline text icons into the Icon Library
3. Make sure the icon is exactly the size you want it. A good way to ensure this
is to make a test document with the icon inline, then copy paste it to the Icon Library
4. Name the icon layer whatever you want, but that's the placehold text you put in your text to replace\
I recommend using [[Icon Name]]
e.g. if you name the icon layer [[Gold]], the script will replace all instances of "[[Gold]]"
in your text with that icon
5. Run the script!ADVANCED USE
6. You'll notice that your icons are much higher up in the text box than they should be
7. To fix this, in the icon name in the layer panel, after the text you want to replace,
add a number after an exclamation pooint (like !-10). This will adjust the icon
that many pixels when running the script. So [[Gold]]!-10 (still keeping [[Gold]] in your text)
8. A quick way to figure out what the adjustment number should be is to have a test document in
InDesign and put the icon in the text like you want it, then select the inline icon and go to
Objects --> Anchored Object --> Options and copy the Y Offset====================================*/
var document = app.activeDocument;
var pages = document.pages;
var layers = document.layers;//Look for an open document called Icon Library
var iconLibDoc = app.documents.itemByName("Icon Library.indd");//First, get the icons in the first layer of the icon library
var iconLibraryLayer = iconLibDoc.layers.firstItem();//Next, duplicate them into the main doc.
//For each icon in the layer, duplicate it to the active document and add it to a list.
var dupedIcons = [];
var iconsToDupe = iconLibraryLayer.allGraphics;
for (var i = 0; i<iconsToDupe.length; i++){
dupedIcons.push(iconsToDupe[i].parent.duplicate(layers[0])); //Note that we grab the parent, which is the frame in the layer, not the graphic itself, in order to preserve the name
}var mergedIcons = [];
//for each icon in the Icon Library, back in the main document
for (var i = 0; i<dupedIcons.length; i++){var icon = dupedIcons[i];
//first, we check to see if we've already merged this icon
var notYetMerged = true;
for (var j = 0; j<mergedIcons.length; j++){
if(mergedIcons[j]===icon.name){
notYetMerged = false;
}
}//if we haven't already merged this icon
if(notYetMerged){//select the icon, then copy it to clipboard
app.select(icon);
app.copy();//first, separate the anchored object adjustment number (anything after a ! in the layer name)
//it's going to replace things that have the left of the !, so [[Brute]]!-5 will replace all
//[[Brute]] text in the text boxes with the contents of this layer
var name = icon.name.split("!")[0];
var adjustment = icon.name.split("!")[1];//Now, by default all anchored objects are placed at the top of the line of text. This is bad.
//If the layer name has the style [[Brute]]!-5 we want it it to adjust the placement of the
//anchored object down 5 units//alert("merging "+name+" with adjustment "+adjustment);
//So by default set the anchored object setting back to 0
document.anchoredObjectDefaults.anchoredObjectStyle.anchoredObjectSettings.anchorYoffset=0;
if(!isNaN(adjustment)){ //then, as long as the adjustment is a number
document.anchoredObjectDefaults.anchoredObjectStyle.anchoredObjectSettings.anchorYoffset=adjustment; //set the adjustemnt
}//find all instances of the icon name in the text and replace with clipboard contents
app.findTextPreferences=app.changeTextPreferences=null;
app.findTextPreferences.findWhat=name;
app.changeTextPreferences.changeTo="^c";
var results = app.activeDocument.changeText();mergedIcons.push(icon.name);
icon.remove(); //Finally, delete the icon from the main document (they're still fine in the library)
}}
-
Delano Dolphy commented
This feature is MASSIVELY NEEDED!
-
Steve Conor commented
Γεια, διάβασα το ποστ σου για το DataMerge και τα inline icons. Ενώ έψαχνα έναν τρόπο να χαλαρώσω μετά από σύνθετες εργασίες, βρήκα το https://spinogambino.com.gr. Είναι πολύ ομαλό για παίκτες από την Ελλάδα. Δοκίμασα μερικά φρουτάκια, έχασα λίγο στην αρχή, αλλά μετά ήρθε μια μικρή νίκη που έκανε τη συνεδρία διασκεδαστική και χαλαρωτική. Ένας απλός τρόπος για διάλειμμα από πολύπλοκες εργασίες σχεδίασης.
-
Joe A (Sykres) commented
It's 100% necessary. Data Merge is a woefully incomplete feature without being able to merge images inline with text.
I'm currently staring down the Bartel of HUNDREDS of additional hours of work simply because I can't do this one small thing with InDesign.