Issue with Reading Variable Data from DataSet in Illustrator 29.5
Dear Adobe Support Team,
I am reaching out to report an issue with Adobe Illustrator (version 29.5) regarding the inability to read variable data from a DataSet object in a script, even though the dataset is correctly loaded and updates the document content as expected.
Problem Description
I have a script that processes a CSV file to generate PDF files using variable data in Illustrator. The CSV file contains columns "Cislo" (number) and "JMENO" (name), and it is correctly loaded into Illustrator as a dataset (via Window > Utilities > Variables > Load Variable Library). The dataset updates the document content correctly—when I call dataSets[i].display(), the text fields in the document update with the correct values (e.g., "1", "URBAN" for the first dataset). However, when I attempt to read the variable values programmatically from the DataSet object (e.g., via dataSets[i].variables[j].content), the script fails to retrieve any values, resulting in empty strings.
Steps We Tried
We have tried multiple approaches to read the variable values, but none of them worked as expected:
Reading via dataSets[i].variables[j].content:
We iterated through dataSets[i].variables, checked the variable names (e.g., variable.name === "Cislo"), and attempted to read the content property.
Result: The content property always returned an empty string, even after calling dataSets[i].display().
Reading via getByName:
We tried using dataSets[i].variables.getByName("Cislo").content to directly access the variable's value.
Result: This threw an error ("Error 21: undefined is not an object") if the variable was not found, and even when wrapped in a try-catch block, it returned an empty string.
Reading via variable.textFrames[0].contents:
We attempted to access the text frame linked to the variable using doc.variables[j].textFrames[0].contents after dataSets[i].display().
Result: This approach also returned empty strings, even though the text frames in the document were visibly updated with the correct values.
Workaround (Successful but Manual):
As a workaround, we named the text frames in the document ("CisloText", "JmenoText") and read their values directly using doc.textFrames.getByName("CisloText").contents.
Result: This worked and correctly retrieved the values (e.g., "1", "URBAN"), confirming that the dataset and variables are functioning as expected for updating the document. However, this is not a practical solution as it requires manual naming of text frames, which is not feasible for larger workflows.
Observations
The CSV file is correct and properly formatted:
Cislo,JMENO
1,URBAN
2,JIŘÍ
3,TOMÁŠ
4,EDA
5,
6,NOVOTNÝ
7,KAREL
The dataset updates the document content correctly when dataSets[i].display() is called (e.g., the text fields show "1", "URBAN" in the UI).
The generated PDF files contain the correct content based on the dataset, confirming that the dataset and variables are working.
However, all attempts to programmatically read the variable values from the DataSet object (dataSets[i].variables) result in empty strings or errors.
Sample Script testVariableReading.jsx:
var doc = app.activeDocument;
var dataSets = doc.dataSets;
// Kontrola, zda existují sady dat
if (!dataSets || dataSets.length === 0) {
alert("Error: No datasets found in the document. Please load a CSV file with variables.");
} else {
for (var i = 0; i < dataSets.length; i++) {
dataSets[i].display(); // Aktivuje sadu dat (mění proměnné – Cislo, JMENO)
// Pokus o načtení hodnot z dataSets[i].variables (selhává)
var currentCisloFromDataSet = "";
var currentJmenoFromDataSet = "";
try {
var variables = dataSets[i].variables;
for (var j = 0; j < variables.length; j++) {
var variable = variables[j];
var varName = variable.name;
if (varName === "Cislo") currentCisloFromDataSet = variable.content || "";
if (varName === "JMENO") currentJmenoFromDataSet = variable.content || "";
}
} catch (e) {
alert("Error reading variables from dataset " + (i + 1) + ": " + e);
}
// Načtení hodnot z pojmenovaných textových polí (funguje)
var currentCisloFromTextFrame = "";
var currentJmenoFromTextFrame = "";
try {
var cisloTextFrame = doc.textFrames.getByName("CisloText");
if (cisloTextFrame) currentCisloFromTextFrame = cisloTextFrame.contents || "";
var jmenoTextFrame = doc.textFrames.getByName("JmenoText");
if (jmenoTextFrame) currentJmenoFromTextFrame = jmenoTextFrame.contents || "";
} catch (e) {
alert("Error reading text frames for dataset " + (i + 1) + ": " + e);
}
// Zobrazení výsledků pro srovnání
alert(
"Dataset " + (i + 1) + ":\n" +
"From dataSets[i].variables:\n" +
"Cislo=" + currentCisloFromDataSet + ", JMENO=" + currentJmenoFromDataSet + "\n\n" +
"From textFrames.getByName:\n" +
"Cislo=" + currentCisloFromTextFrame + ", JMENO=" + currentJmenoFromTextFrame
);
}
}
Request
It seems there might be a bug in Illustrator 29.5 where the DataSet object's variables property does not correctly expose the content of variables after display() is called. I would appreciate if you could investigate this issue and provide a solution or workaround to programmatically read the variable values from a dataset without relying on manually named text frames.
Attachments
I am attaching the following files for your reference:
The CSV file (data.csv) used to load the dataset.
A sample file (sample.pdf) with the variables and dataset set up, where the issue can be reproduced. I have saved the file as a PDF because the original .ai file was rejected due to a content type mismatch (application/postscript). The PDF was saved with "Preserve Illustrator Editing Capabilities" enabled, so you should be able to open it in Illustrator and see the variables and dataset. Note that the text frames in this file are already named "CisloText" and "JmenoText" as part of the workaround, so reading via doc.textFrames.getByName("CisloText").contents will work. However, the issue with reading directly from dataSets[i].variables should still be reproducible.
A test script (testVariableReading.txt) that demonstrates the issue. Please note that I could not attach the script with its original .jsx extension as it is not a supported file type. I have renamed it to testVariableReading.txt. To test the script, please rename it back to testVariableReading.jsx. The script attempts to read variable values both from dataSets[i].variables (which fails) and from named text frames (which works), and displays the results in an alert for comparison.
Thank you for your assistance! Please let me know if you need any additional information to investigate this issue.
Best regards,
Ales Ulrych
