How to find out the textframe contains "stroke color" (or) "fillcolor" via javascript. Kindly advise me with sample.
Hi Maria, try this
var idoc = app.activeDocument;
var itext = idoc.textFrames[0];
//alert(itext.textRange.characterAttributes.fillColor);
var fillColor = itext.textRange.characterAttributes.fillColor;
var strokeColor = itext.textRange.characterAttributes.strokeColor;
filled = stroked = "yes";
if (fillColor=="[NoColor]")
filled = "No";
if (strokeColor=="[NoColor]")
stroked = "No";
alert("Filled: " + filled + "\n" + "Stroked: " + stroked);
Maria, if you are talking about the path of an 'area text frame' then you need to look at it's 'text path' to read the properties of that… Eg
#target illustrator
var doc = app.activeDocument;
var tFrame = doc.textFrames[0];
if (tFrame.textPath.filled) {
alert( 'Text Frame is filled with ' + tFrame.textPath.fillColor.typename );
};
if (tFrame.textPath.stroked) {
alert( 'Text Frame is stroked with ' + tFrame.textPath.strokeColor.typename );
};
I know, this post is quite a while ago, but: This simply does not work for me. Neither for simple PathItems, nor for the characters of a TextFrame.
Working on: Illustrator CS5.5, Mac OS, Javascript
Simple example:
var numSelectedObjects = app.activeDocument.selection.length;
// If any objects selected: Get fill and stroke color of the first one
if(numSelectedObjects > 0){
alert("Fill Color: " + app.activeDocument.selection[0].fillColor + " / Stroke Color: " + app.activeDocument.selection[0].fillColor);
}
This returns always CMYKColor, RGBColor or GrayColor, even if there is no Color assigned to the objects stroke or fill!!
For PathItems there is the attribute ".filled" or ".stroked", which returns "true" or "false" and is reliable.
if(app.activeDocument.selection[i].filled){ // works fine with PathItems!
Is there anything similar for Characters? I tried this one, but it does not work (because I think it does not exist):
if(app.activeDocument.selection[i].textRange.filled){ // does not work!
I just need to find out, if the characters in a textfield have got a fill or stroke color. Reliable.
It would be very nice to get help from anybody!
Thanks a lot in advance!
North America
Europe, Middle East and Africa
Asia Pacific