Copy link to clipboard
Copied
Hi,
I'm very new to scripting and I'm in the middle of developing a small script that imports data of a csv (only one dataset) and exports that dataset as a pdf.
The step I'm struggling with is, after importing the csv and the variables are visible in the panel, I need to make them dynamic and bind them to their respective objects before I can export the document.
Ideally, I would like it bind them by name (as it's possible with the variableImporter.jsx script) so that they bind to objects that have the same name as the variables themselves.
However, I don't really get how to do this. The closest info to this solution I've found is this one, where all text is made dynamic by creating a variable:
https://community.adobe.com/t5/illustrator/script-to-make-all-text-dynamic/td-p/3521197?page=1
But I don't seem to find anything that relates to binding the already imported variables.
Any ideas?
I'm grateful for any tips.
if the variables are already made, you would loop through each of them, find an object with the same name as the variable then assign the variable to its contentVariable property.
var idoc = app.activeDocument;
var variables = idoc.variables;
for (var a=0; a<variables.length; a++) {
idoc.pageItems[variables[a].name].contentVariable = variables[a];
}
Copy link to clipboard
Copied
if the variables are already made, you would loop through each of them, find an object with the same name as the variable then assign the variable to its contentVariable property.
var idoc = app.activeDocument;
var variables = idoc.variables;
for (var a=0; a<variables.length; a++) {
idoc.pageItems[variables[a].name].contentVariable = variables[a];
}
Copy link to clipboard
Copied
Wow, thank you so much Carlos!
You're a life saver!