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

creating outlines from text using javascript in Illustrator CS5

Explorer ,
Feb 18, 2012 Feb 18, 2012

Hi everyone,

Is there a way to select all of the text on all artboards and CREATE OUTLINES using Javascript? I've googled and googled, but I can't seem to find any help. The text that Adobe provides for scripting has this option for saving to FXGs which is preserveTextPolicy or something similar, but I need the same type of solution for saving as an AI file or as a command before the save. I'm currently working in windows, but am writing this script for use on a MAC. If there isn't an internal way of doing this through Javascript, does anyone know of another?  I would imagine it would be possible through Applescript since it can access the application's GUI, but I'm not sure. A javascript solution would be preferable, but any solution would work at this point.

thanks,

Matt

TOPICS
Scripting
9.0K
Translate
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

Guru , Feb 18, 2012 Feb 18, 2012

The something like this may work… Should outline text at all depths wether it be locked or not visible… Sure it was posted here before… JS so you can try it on either platform…

#target illustrator

function outlineDocText(  ) {

          if ( app.documents.length == 0 ) return;

 

  var docRef = app.activeDocument;

 

          recurseLayers( docRef.layers );

 

};

outlineDocText();

function recurseLayers( objArray ) {

 

          for ( var i = 0; i < objArray.length; i++ ) {

 

                    // Record

...
Translate
Adobe
Guru ,
Feb 18, 2012 Feb 18, 2012

There is a built-in command for this in all the scripting languages AI supports its a straight forward method of text.createOutlines()

Translate
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
Explorer ,
Feb 18, 2012 Feb 18, 2012

Thanks for the response. Something straightforward is what I was looking for,but will that affect all text that even though it wasn't created with javascript like TextFrame.add or similar? And if so, could you provide a little sampling of this code if you have the time? That would be a huge help!

thanks

Translate
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
Guru ,
Feb 18, 2012 Feb 18, 2012

The something like this may work… Should outline text at all depths wether it be locked or not visible… Sure it was posted here before… JS so you can try it on either platform…

#target illustrator

function outlineDocText(  ) {

          if ( app.documents.length == 0 ) return;

 

  var docRef = app.activeDocument;

 

          recurseLayers( docRef.layers );

 

};

outlineDocText();

function recurseLayers( objArray ) {

 

          for ( var i = 0; i < objArray.length; i++ ) {

 

                    // Record previous value with conditional change

                    var l = objArray.locked;

                    if ( l ) objArray.locked = false;

 

                    // Record previous value with conditional change

                    var v = objArray.visible;

                    if ( !v ) objArray.visible = true;

 

                    outlineText( objArray.textFrames );

 

                    // Recurse the contained layer collection

                    if ( objArray.layers.length > 0 ) {

                              recurseLayers( objArray.layers )

                    }

 

                    // Recurse the contained group collection

                    if ( objArray.groupItems.length > 0 ) {

                              recurseGroups( objArray.groupItems )

                    }

 

                    // Return to previous values

                    objArray.locked = l;

                    objArray.visible = v;

          }

};

function recurseGroups( objArray ) {

 

          for ( var i = 0; i < objArray.length; i++ ) {

 

                    // Record previous value with conditional change

                    var l = objArray.locked;

                    if ( l ) objArray.locked = false;

 

                    // Record previous value with conditional change

                    var h = objArray.hidden;

                    if ( h ) objArray.hidden = false;

 

                    outlineText( objArray.textFrames );

 

                    // Recurse the contained group collection

                    if ( objArray.groupItems.length > 0 ) {

                              recurseGroups( objArray.groupItems )

                    }

 

                    // Return to previous values

                    objArray.locked = l;

                    objArray.hidden = h;

          }

};

function outlineText( objArray ) {

 

          // Reverse this loop as it brakes the indexing

          for ( var i = objArray.length-1; i >= 0; i-- ) {

 

                    // Record previous value with conditional change

                    var l = objArray.locked;

                    if ( l ) objArray.locked = false;

 

                    // Record previous value with conditional change

                    var h = objArray.hidden;

                    if ( h ) objArray.hidden = false;

 

                    var g = objArray.createOutline(  );

 

                    // Return new group to previous Text Frame values

                    g.locked = l;

                    g.hidden = h;

 

          }

};

Translate
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
Explorer ,
Feb 18, 2012 Feb 18, 2012

You are the Jedi Master of Illustrator Scripting! thanks for this script. This will work and I just found another link where you helped someone else. You are truly amazing!! Thanks

Translate
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
Guru ,
Feb 18, 2012 Feb 18, 2012

Hum… I've seen muppets in space and I don't recall any of them having the force…

Translate
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
Explorer ,
Feb 18, 2012 Feb 18, 2012

...well now one of them does. Thanks again for the help.

Translate
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
New Here ,
Aug 08, 2013 Aug 08, 2013
LATEST

Hey Muppet Mark! I was hoping you could help me further this bit of scripting. I'd like to save a copy of the illustrator file and then create and save an outlined version, adding OUTLINE to the end of the file name. Is this doable? I'm just not sure where to add in the AIOptions and such... Could you help me?

Translate
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