Copy link to clipboard
Copied
I want to create storke in text in illustrator scripting and found one method too createoutline(),But How i used this method for text outline.
Copy link to clipboard
Copied
#target illustrator
var idoc = app.activeDocument;
var tf = idoc.textFrames;
for ( t = tf.length-1; t >= 0; t-- ) {
var text = tf
; text.createOutline();
}
alert ( "All text converted to outlines." );
Copy link to clipboard
Copied
Yeah, i used like this. its creating outline but replace text frame to outline .I need textframes and outline both having different colors.
Thanks in advance
Copy link to clipboard
Copied
Then I suppose you could use:
a for loop to select all of the text items.
app.executeMenuCommand ('copy')
menu command deselect all
the previous for loop to create outlines
menu command past in front
Changing the color of text is a pain in script but you can find an example in this post SpotColor to GrayColor converter (javaScript) starting at line 82 in the script.
Good luck
Copy link to clipboard
Copied
var docRef = app.activeDocument;
var colorForText = new CMYKColor();
colorForText.black = 0;
colorForText.cyan = 0;
colorForText.magenta = 0;
colorForText.yellow = 0;
var colorForTextOutline = new CMYKColor();
colorForTextOutline.black = 100;
colorForTextOutline.cyan = 0;
colorForTextOutline.magenta = 0;
colorForTextOutline.yellow = 0;
var outlineSize = 5;
for (i = docRef.textFrames.length-1; i >=0; i--) {
for (j = 0; j < docRef.textFrames.words.length; j++){
docRef.textFrames.words
.filled = true; docRef.textFrames.words
.fillColor = colorForText; }
var outline = docRef.textFrames.duplicate(docRef, ElementPlacement.PLACEATEND);
for (h = 0; h < outline.words.length; h++) {
outline.words
.filled = true; outline.words
.fillColor = colorForTextOutline; outline.words
.stroked = true; outline.words
.strokeColor = colorForTextOutline; outline.words
.strokeWeight = outlineSize;
}
//docRef.textFrames.createOutline();
//outline.createOutline();
}
createOutline(); converts live text to outlines, if you are trying to just create a stroke you have to go about it a different way. This script will take the text and copy it, put it in back, and put a stroke behind on the behind text so it has an effect similar to an offset path. The way I have it leaves the text live, if you were wanting to convert the text to outlines as well I left that part written in the bottom of the script. There is also a StrokeJoin parameter as well.
Hope this helps!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now