Skip navigation
Currently Being Moderated

How to find out the textframe contains "stroke color" (or) "fillcolor"?

Jul 5, 2011 4:16 AM

How to find out the textframe contains "stroke color" (or) "fillcolor" via javascript. Kindly advise me with sample.

 
Replies
  • Currently Being Moderated
    Jul 5, 2011 11:47 AM   in reply to Maria prabhudoss

    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);
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 6, 2011 2:50 AM   in reply to CarlosCanto

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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 26, 2012 1:11 AM   in reply to CarlosCanto

    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!

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 26, 2012 2:13 AM   in reply to tpa_gru_flo

    The post above was for the containing path of an area text frame where it is filled and stroked… Not the text contents… For text within a frome you will need check the character attributes of each in a loop…

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 26, 2012 4:11 AM   in reply to Muppet Mark

    As you might see in the headline of my message: My post was referenced to Carlos Canto's Post, who was talking about "[NoColor]" and that stuff.

     

    SO you know that i can use ".filled" on a single character object? I'll try! Thanks for your hint!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points