Mobile app version of vmapp.org
Login or Join
Holmes874

: Illustrator script to convert multiple files into outlines with a pdf preset Can someone help with an illustrator script that can convert text from multiple files in a folder to outlines and

@Holmes874

Posted in: #AdobeIllustrator #IllustratorScripting #Pdf #Script #Text

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:
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.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Holmes874

1 Comments

Sorted by latest first Latest Oldest Best

 

@Shelley591

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;

}

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme