Trying to convert text to outline via duplicated text layer
New to illustrator scripting, and right now i have a script that will take a data, map values into text inputs, then export pdfs.
What i'm trying now is to take each of the text inputs and convert them to outlines. My thought here is I could take and duplicate the textFrame, hide the initial one, create the outline to the new one, export the pdf, then remove out those items, and finally toggle back on the original.
```
function exportDataSets(allModifiedTextFrames) {
try {
for (var i = 0; i < doc.dataSets.length; i++) {
alert('exportDataSets' + i)
doc.dataSets[i].display();
redraw();
var duplicateTextFrames = [];
allModifiedTextFrames[i].forEach(function (textFrame) {
textFrame.hidden = true;
var duplicateTextFrame = textFrame.duplicate();
duplicateTextFrame.createOutline();
duplicateTextFrames.push(duplicateTextFrame);
});
var pdfSaveOptions = new PDFSaveOptions();
var destFile = getPDFFileNameFromDoc(doc.dataSets[i].name);
doc.saveAs(new File(destFile), pdfSaveOptions);
duplicateTextFrames.forEach(function (textFrame) {
textFrame.remove();
});
// Restore original text frame visibility
allModifiedTextFrames[i].forEach(function(textFrame) {
textFrame.hidden = false;
});
alert('Unhide frames');
}
} catch (e) {
alert('error exportDataSets')
alert(e);
}
}
What I keep hitting is Object invalid when doing the .remove();
What am I missing here?
