5 Replies Latest reply: Apr 26, 2012 4:11 AM by tpa_gru_flo RSS

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

    Maria prabhudoss Community Member

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

        • 1. Re: How to find out the textframe contains "stroke color" (or) "fillcolor"?
          CarlosCanto MVP

          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);
          
          • 2. Re: How to find out the textframe contains "stroke color" (or) "fillcolor"?
            Muppet Mark Community Member

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

            • 3. Re: How to find out the textframe contains "stroke color" (or) "fillcolor"?
              tpa_gru_flo

              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!

              • 4. Re: How to find out the textframe contains "stroke color" (or) "fillcolor"?
                Muppet Mark Community Member

                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…

                • 5. Re: How to find out the textframe contains "stroke color" (or) "fillcolor"?
                  tpa_gru_flo Community Member

                  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!