Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
3

Trying to convert text to outline via duplicated text layer

New Here ,
Oct 23, 2023 Oct 23, 2023

Copy link to clipboard

Copied

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?

TOPICS
How-to , Scripting

Views

143
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

New Here , Oct 23, 2023 Oct 23, 2023

Bah finally figured it out.

 

I needed to return the createOutline() group into my array,  as it appears the duplicated item does not persist once createOutline is used.

 

Once I returned the createOutline() and got the Group returned, all was good.

Votes

Translate
Adobe
New Here ,
Oct 23, 2023 Oct 23, 2023

Copy link to clipboard

Copied

Bah finally figured it out.

 

I needed to return the createOutline() group into my array,  as it appears the duplicated item does not persist once createOutline is used.

 

Once I returned the createOutline() and got the Group returned, all was good.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 23, 2023 Oct 23, 2023

Copy link to clipboard

Copied

LATEST

Because createOutline() is destructive, it creates a new object that is written to a variable. The same is true if you have an object with an effect and you do Expand. For example, if you have an object selected, after the destructive action you can retrieve it by accessing app.selection[0]. These are the nuances of working with scripts in Illustrator.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines