Adding Stoke to text with Extendscript

Copy link to clipboard
Copied
Can a stoke effect be added programatically to a text object using Extendscript with Illistrator CS3 or CS4?
Wish to be able to set the stroke size and color to an existing text object. Have not been able to find a programatic way to do this. Can this be done with Extendscript/Javascript?
Any information on this would be very appreciated.
thanks
M
.
Explore related tutorials & articles
Copy link to clipboard
Copied
With an open CMYK doc containing 1 text frame with 3 paragraphs of chunky 120 pt type I was able to add both stroke and color like so…
#target illustrator
var docRef = app.activeDocument;
with (docRef) {
with (textFrames[0]) {
for (var i = 0; i < characters.length; i++) {
randCMYK = new CMYKColor();
randCMYK.cyan = Math.round(Math.random() * 100);
randCMYK.magenta = Math.round(Math.random() * 100);
randCMYK.yellow = Math.round(Math.random() * 100);
randCMYK.black = Math.round(Math.random() * 100);
characters.characterAttributes.strokeWeight = Math.round(Math.random() * 10);
characters.characterAttributes.strokeColor = randCMYK;
}
}
}

Copy link to clipboard
Copied
Hi Muppet,
Thank you for your reply and example it works correctly. Appreciate your response. It was very helpful,
--------------------------------------------------------------------------------------
One issue I am seeing with Stroke in Illistrator is that the stroke effect applies inward to the text and not outward. This is a actually a problem with my needs as I are converting some designs programatically from scripts. The designs contain text stroke, but the Stroke effect expand outward, where Illistrators Stroke effect expands inward. The inward effect of the stroke which Illistrator uses does not work well with the conversion and I need to try to automate this process so the converted design looks correct in illistrator. .
I'm wondering if effects can be applied with extendscript code as well. A couple of options to "fake" the stroke effect going outward, might be to set a drop shadow in all 4 directions. Or possible an outward glow effect. Can Drop shadow and Glow effects be set in extendscript?
Thanks for any help on this.
M
Copy link to clipboard
Copied
Im using CS2 and don't think that you can alter the stroke in the way you want. With path items in the GUI you have 3 options for strokes inside, outside & on centre. You can't do this with type but you can do in appearance pallet is something similar moving single/multi strokes behind the fills. Im almost certain that you don't have access to this via script? You could duplicate your text frame and just add the stroke to the text at the back (which is basically what the appearance thing does)

