0

Can someone help with an illustrator script that can convert text from multiple files in a folder to outlines and save it to pdf with a specific preset of my choice?

Was able to find from my research on the adobe forums some lines of code, but was unsuccessful in combining them to work somehow.

What i've found:

https://forums.adobe.com/thread/964576

    #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; }

};

Thank you.

  • You should probably use print flattener instead of this. – joojaa Feb 23 '18 at 9:12
  • You can outline text in PDF files in batch by making a droplet using a preflight preset called: Convert fonts to outlines in Acrobat Pro. – Joonas Feb 23 '18 at 11:57
0

Was able to get what i wanted. Convert strokes and text to outlines and save all the files to PDF X-3. Used some code parts from other questions and answers surrounding similar problems. Here it is what worked for me:

try {  

app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS; 

if (app.documents.length > 0 ) { 

var destFolder = null; 

destFolder = Folder.selectDialog( 'Select folder for PDF files.', '~'); 

if (destFolder != null) { 

var options, i, sourceDoc, targetFile; 

options = this.getOptions();  

while (app.documents.length > 0) { 

sourceDoc = app.activeDocument

app.executeMenuCommand("selectall");
app.executeMenuCommand("OffsetPath v22");  
app.executeMenuCommand("outline");



targetFile = this.getTargetFile(sourceDoc.name, '.pdf', destFolder); 

sourceDoc.saveAs( targetFile, options ); 
app.activeDocument.close();

} 

alert( 'Documents saved as PDF' ); 

} 

} 

else{ 

throw new Error('There are no document open!'); 

} 

} 

catch(e) { 

alert( e.message, "Script Alert", true); 

} 

function getOptions() 

{ var NamePreset = '[PDF/X-3:2002]'; 

var options = new PDFSaveOptions(); 

options.pDFPreset=NamePreset;  

return options; 

} 

function getTargetFile(docName, ext, destFolder) { 

var newName = ""; 

if (docName.indexOf('.') < 0) { 

newName = docName + ext; 

} else { 

var dot = docName.lastIndexOf('.'); 

newName += docName.substring(0, dot); 

newName += ext; 

}  

var myFile = new File( destFolder + '/' + newName ); 

if (myFile.open("w")) { 

myFile.close(); 

} 

else { 

throw new Error('Access is denied'); 

} 

return myFile; 

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.