Copy link to clipboard
Copied
Hi there, anyone knows if Illustrator has Data Merge function?
or InDesign Data Merge 'alike' function in Illustrator?
Thank you.
That is a good video, but it's kind of old-method. Don't get me wrong, we would not have the new method now if we didn't have Joao's online converter along with other tutorials and script snippets people put together, which paved the way. Now, we have the VariableImporter script as well as John Garrett's in-depth video tutorials on the subject, including the one on Lynda/LinkedIn Learning, about Variable Data in Illustrator!
Copy link to clipboard
Copied
the closest thing to data merge is the use of Variables and Data Sets in Illustrator
Copy link to clipboard
Copied
Thanks.
Variables and Data Sets in Illustrator is not that "friendly" nor easily be programmable as InDesign's Data Merge function..
(sob)
Copy link to clipboard
Copied
I know, they are very unfriendly...but it is THE only option...is there anything in particular you're after?
Copy link to clipboard
Copied
reasons:
1. my data are mostly in TEXT and XLS file.
2. XML format is not that easily scriptable
Copy link to clipboard
Copied
Save the XLS as a CSV file and parse in script.
Copy link to clipboard
Copied
I ceated an mac application called "Varistrator" that allolws you to define the variables in illustrator and assign them to the matching colums in an excel spreadsheet. It has options to use the variables in the names. It can generate eps and or pdf files on save. It could be done just using applescript or javascript but the frontend makes so no programming is needed.
I have not updated it for years and it does not work in Lion...
Copy link to clipboard
Copied
Copy link to clipboard
Copied
@JET
that's good... provided the database is relatively small.
are there any solutions for something a little more industrial... such as records in the thousands or tens-hundreds of thousands?
not trying to be an antagonist, but I really do deal with databases this size, and at the moment use adobe indesign's Data Merge feature to handle merges like this. However, indesign can't warp or distort live text, so to use these effects, making variable graphics in illustrator is a workaround.
there are plugins like XMPie and DirectSmile, but i want to do as much as i can with the off-the-shelf creative suite as i can.
Copy link to clipboard
Copied
I work with spreadsheets up to 2500 rows large routinly using extendscript and parsing a CSV file to step and repeat a 'template' design while replacing text/images in that template with those from the CSV file. Though it does take some time, I've had no problems being able to work with that size of a list. I don't know that you'll find anything optimised with scripting as far as speeds, you might want to look into illustrator's SDK to do what you're after.
Copy link to clipboard
Copied
Thank you SO MUCH for posting this information. I passed it along to a designer who was looking for exactly this solution, and I know she will be very grateful.
Copy link to clipboard
Copied
The newest script for this is described here:
Illustrator Variable Data - The EASY way! - YouTube
And most in-depth here:
Copy link to clipboard
Copied
Here is a video I watched that helped me, it is a tutorial using Variables and an online service to convert Excel to XML
How to use variable data in adobe Illustrator - YouTube
I hope it will also help you.
Copy link to clipboard
Copied
That is a good video, but it's kind of old-method. Don't get me wrong, we would not have the new method now if we didn't have Joao's online converter along with other tutorials and script snippets people put together, which paved the way. Now, we have the VariableImporter script as well as John Garrett's in-depth video tutorials on the subject, including the one on Lynda/LinkedIn Learning, about Variable Data in Illustrator!
Copy link to clipboard
Copied
I don't like Illustrator's wa of handling variable data either.
When setting up AI files with multiple different contents I use top level layers to do the job:
1) Set up one layer for elements that are identical in all versions
2) Set up one layer for each version, named with a keyword (in my case "Sorte_...")
Switching through these versions is like turning visibility of the layers on and off.
When the job is finished I split the versions using a script that turns off all top level layers named with the keyword, creating a new folder, then turning on and off one version layer after another and saving the AI file in the new folder, always with a new file name (original file name + version layer name without keyword). After the script has finished I have a new folder with as many AI files as there are version layers in my master file.
Copy link to clipboard
Copied
Do you mind posting your script for saving layers by keywords? I imagine it is simple and I could write it up myself, I think, but if you didn't mind I would like to see how you did it.
I also struggle with using variables because of the different options I need to save, but if I had a script that could assign variables to layers and then save those layers, that sounds like it would solve my problem.
Thanks!
Copy link to clipboard
Copied
var doc = app.activeDocument;
var splitfolder = "_SPLIT";
var arr = doc.name.split(".");
var extension = "";
if (arr.length>1) extension = "." + arr.pop();
var filename = arr.join(".");
var foldername = filename;
var export_folder = "~/Desktop/" + foldername + splitfolder;
var assets_folder = new Folder (export_folder);
assets_folder.create();
function hide_layer (a) {
var docHide = app.activeDocument;
var myLayers1 = docHide.layers;
var hideName1 = a;
try {
hideLayer1 = myLayers1.getByName (hideName1);
hideLayer1.visible = false;
redraw();
}
catch (e) {}
}
function show_layer (a) {
var docShow = app.activeDocument;
var myLayers2 = docShow.layers;
var showName2 = a;
try {
showLayer2 = myLayers2.getByName (showName2);
showLayer2.visible = true;
redraw();
}
catch (e) {}
}
var myLayers = [];
var layerCount = doc.layers.length;
for (var ii = layerCount - 1; ii >= 0; ii--) {
var currentLayer = doc.layers[ii];
myLayers.push (currentLayer);
}
for (var ii = layerCount - 1; ii >= 0; ii--) {
var isSorte = (myLayers[ii].name).indexOf("Sorte"); // <---
if (isSorte >= 0) {
hide_layer (myLayers[ii].name);
}
}
for (var ii = layerCount - 1; ii >= 0; ii--) {
var isSorte = (myLayers[ii].name).indexOf("Sorte"); // <---
if (isSorte >= 0) {
show_layer (myLayers[ii].name);
var actLayName = myLayers[ii].name;
actLayName = actLayName.replace (/Sorte/,""); // <---
var sortFileName = filename;
sortFileName = sortFileName.replace(/_MULTI/,actLayName); // <---
var save_options = new IllustratorSaveOptions();
save_options.embedICCProfile = false;
save_options.pdfCompatible = false;
var packaged_file = File (export_folder + "/" + sortFileName);
doc.saveAs(packaged_file, save_options);
hide_layer (myLayers[ii].name);
}
}
doc.close (SaveOptions.DONOTSAVECHANGES);
doc.saveAs(packaged_file, save_options); | |
hide_layer (myLayers[ii].name); | |
} | |
} |
doc.close (SaveOptions.DONOTSAVECHANGES);
Description:
You create your master file with top level layers for each data set and other top level layers which will be visible in all sets. There's a convention for naming the layers: each data set requires the keyword "Sorte" at the beginning. You can alter that if you like in the script in lines 46, 53, 59.
There needs to be a keyword in your master file's name, too: "MULTI" has to be part of the file name.
When running the script it will do the following:
- generate a new folder on your desktop, named as the master file plus suffix _SPLIT because it's going to split up the master file into the different master sets as single .ai files.
- hide all top level layers that contain the keyword "Sorte" in their names
- show the first top level layer that contains the keyword "Sorte"
- save a copy of the .ai file in it's current state inside the new folder
*** and here comes the magic: the script extracts the layer's name, strips of the keyword "Sorte", replaces the keyword "MULTI" in the file name wit the rest of the layer's name and saves the file with that new name ***
- hide the first top level layer that contains the keyword "Sorte"
- show the second top level layer that contains the keyword "Sorte"
- save a copy of the .ai file in it's current state inside the new folder
*** again the magic 🙂 ***
- hide the second top level layer that contains the keyword "Sorte"
... and so on and so forth.
After running the script you have a new folder containing 1 new file for each data set, and with a unique name based on the layer's name.
There's a second script I use after that: a batch script for creating PDF from .ai files. You'll only have to start the script with no file opened. It'll ask for a folder containing .ai files and then opens all of them (one after another) and exports as PDF. Settings for PDF have to be modified in the script.
var dir = Folder.selectDialog("Choose folder containing .ai files");
var files = dir.getFiles("*.ai");
for (var f = 0; f < files.length; f++) {
var doc = app.open(files
); var pdfFile = new File(app.activeDocument.fullName.toString().replace(".ai",".pdf"));
var saveOpts = new PDFSaveOptions();
saveOpts.pDFPreset = 'Ansichts-PDF 150dpi'; // Name of PDF settings
saveOpts.viewAfterSaving = false;
app.activeDocument.saveAs (pdfFile, saveOpts);
doc.close (SaveOptions.DONOTSAVECHANGES);
}