7 Replies Latest reply: Aug 8, 2013 6:57 AM by williambub RSS

    creating outlines from text using javascript in Illustrator CS5

    duhwellhuh Community Member

      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

        • 1. Re: creating outlines from text using javascript in Illustrator CS5
          Muppet Mark Community Member

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

          • 2. Re: creating outlines from text using javascript in Illustrator CS5
            duhwellhuh Community Member

            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

            • 3. Re: creating outlines from text using javascript in Illustrator CS5
              Muppet Mark Community Member

              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[i].locked;
                                  if ( l ) objArray[i].locked = false;
                
                                  // Record previous value with conditional change
                                  var v = objArray[i].visible;
                                  if ( !v ) objArray[i].visible = true;
                
                                  outlineText( objArray[i].textFrames );
                
                                  // Recurse the contained layer collection
                                  if ( objArray[i].layers.length > 0 ) {
                                            recurseLayers( objArray[i].layers )
                                  }
                
                                  // Recurse the contained group collection
                                  if ( objArray[i].groupItems.length > 0 ) {
                                            recurseGroups( objArray[i].groupItems )
                                  } 
                
                                  // Return to previous values
                                  objArray[i].locked = l;
                                  objArray[i].visible = v;
                        }
              };
              
              function recurseGroups( objArray ) {
                
                        for ( var i = 0; i < objArray.length; i++ ) {
                
                                  // Record previous value with conditional change
                                  var l = objArray[i].locked;
                                  if ( l ) objArray[i].locked = false;
                
                                  // Record previous value with conditional change
                                  var h = objArray[i].hidden;
                                  if ( h ) objArray[i].hidden = false;
                
                                  outlineText( objArray[i].textFrames );
                
                                  // Recurse the contained group collection
                                  if ( objArray[i].groupItems.length > 0 ) {
                                            recurseGroups( objArray[i].groupItems )
                                  } 
                
                                  // Return to previous values
                                  objArray[i].locked = l;
                                  objArray[i].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[i].locked;
                                  if ( l ) objArray[i].locked = false;
                
                                  // Record previous value with conditional change
                                  var h = objArray[i].hidden;
                                  if ( h ) objArray[i].hidden = false;
                
                                  var g = objArray[i].createOutline(  );
                
                                  // Return new group to previous Text Frame values
                                  g.locked = l;
                                  g.hidden = h;
                
                        }
              
              };
              
              
              • 4. Re: creating outlines from text using javascript in Illustrator CS5
                duhwellhuh Community Member

                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

                • 5. Re: creating outlines from text using javascript in Illustrator CS5
                  Muppet Mark Community Member

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

                  • 6. Re: creating outlines from text using javascript in Illustrator CS5
                    duhwellhuh Community Member

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

                    • 7. Re: creating outlines from text using javascript in Illustrator CS5
                      williambub

                      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?