11 Replies Latest reply on Apr 5, 2016 3:15 AM by tpk1982

    Find text Tint Value

    tpk1982 Level 4

      Hi All,

       

      I need to check whether any character have opacity.  I tried the following codings, but it shows all characters as error.

       

      var myframe = app.activeDocument.textFrames;   

      for(i=0; i<myframe.length; i++)   

      {   

          var myCharacters = myframe[i].characters;   

          for(j=0; j<myCharacters.length; j++)   

          {   

               if(myCharacters[j].opacity != 100)   

               {   

                   alert("Error: Check some text has opacity")   

                   }   

              }   

          }   

       

       

      Regards,

      Karthi

        • 1. Re: Find text Tint Value
          b91823603 Level 3

          Hi,

           

          To get the tint value use

          myCharacters[j].fillTint

          • 2. Re: Find text Tint Value
            tpk1982 Level 4

            Hi,

             

            Thanks for your kind reply. It is working in Indesign. If i use this code for illustrator, it wont give results? Any idea how to do this in Illustrator?

             

            Regards,

            Karthi

            • 3. Re: Find text Tint Value
              b91823603 Level 3

              Hi Karthi,

               

              In Illustrator you have to use,

               

              pageItem.opacity = val;

              or

              myCharacters[j].fillColor.tint = val;

              • 4. Re: Find text Tint Value
                tpk1982 Level 4

                Hi b91823603,

                 

                Unfortunately myCharacters[j].fillColor.tint = val; is not working. I asked the same question in Illustrator scripting forum. But that said we can't get opacity value of character.

                Find text Tint Value

                 

                Regards,

                Karthi

                • 5. Re: Find text Tint Value
                  [Jongware] Most Valuable Participant

                  So ... it's a good thing it works correctly in InDesign, right?

                   

                  You got your answer for InDesign here and the answer for Illustrator in the Illustrator forum. I see no reason why you should not believe them in their own field of expertise.

                  • 6. Re: Find text Tint Value
                    tpk1982 Level 4

                    Hi Jongware,

                     

                    Sorry i need both this script for Indesign and Illustrator. So posted in both forums. I hope here some one can give suggestions/answer for Illustrator as well. Because i was not get any answer in that forum. Nothing else. I believe everyone so posted in both forums.

                     

                    Regards,

                    Karthi

                    • 7. Re: Find text Tint Value
                      Laubender Adobe Community Professional & MVP

                      Note: The properties opacity and tint denote two totally different things.
                      You cannot find opacity as text attribute in InDesign for individual characters. Only on pageItems using effects.

                      Opacity is describing some kind of transparency.

                       

                      Example:

                       

                      var doc = app.documents.add();
                      var rect = doc.rectangles.add
                      (
                          {
                              geometricBounds : [0,0,"50mm","50mm"] ,
                              strokeWeight : 0 ,
                              fillColor : "Cyan"
                          }
                      )
                      
                      var textFrameOne = doc.textFrames.add
                      (
                          {
                              geometricBounds : ["10mm","10mm","30mm","90mm"] ,
                              contents : "Opacity: 50" 
                          }
                      );
                      
                      textFrameOne.parentStory.texts[0].properties =
                      {
                          pointSize : 40 ,
                          fillColor : "Black" ,
                          fillTint : 100
                      }
                      
                      
                      textFrameOne.contentTransparencySettings.blendingSettings.properties = 
                      { 
                          blendMode : BlendMode.NORMAL , 
                          opacity : 50 
                      };
                      
                      var textFrameTwo = doc.textFrames.add
                      (
                          {
                              geometricBounds : ["25mm","10mm","45mm","90mm"] ,
                              contents : "Tint value: 50" 
                          }
                      );
                      
                      textFrameTwo.parentStory.texts[0].properties =
                      {
                          pointSize : 40 ,
                          fillColor : "Black" ,
                          fillTint : 50
                      }
                      
                      textFrameTwo.contentTransparencySettings.blendingSettings.properties = 
                      { 
                          blendMode : BlendMode.NORMAL , 
                          opacity : 100 
                      };
                      
                      
                      doc.layoutWindows[0].overprintPreview = true;
                      

                       

                       

                      Overprint Preview off:

                      Example-Opacity50-vs-Tint50-ViewOverprint-OFF.png

                       

                       

                      Overprint Preview on:

                      Example-Opacity50-vs-Tint50-ViewOverprint-ON.png

                       

                      Uwe

                      • 8. Re: Find text Tint Value
                        b91823603 Level 3

                        Hi Karthi,


                        Make sure that you are using spot color type for character fill color. It works for me try this one,

                        myCharacters[j].fillColor.tint = val;

                        • 9. Re: Find text Tint Value
                          tpk1982 Level 4

                          Hi b91823603,

                           

                          Here is final coding which is working for me. It works fine in Indesign.

                           

                          var myframe = app.activeDocument.textFrames; 
                          for(i=0; i<myframe.length; i++) 
                          { 
                              var myCharacters = myframe[i].characters; 
                              for(j=0; j<myCharacters.length; j++) 
                              { 
                                  if(myCharacters[j].fillTint != 100 && myCharacters[j].fillTint != -1)  
                                  { 
                                      alert("Error: Check some text has opacity") 
                                      } 
                                  } 
                              }
                          

                           

                          PS: Thanks Uwe for your awesome explanation. Now i need to find out the issue in Illustrator.

                           

                          Regards,

                          Karthi

                          • 10. Re: Find text Tint Value
                            Laubender Adobe Community Professional & MVP

                            Hi Karthi,

                            I'd change the wording of the alert of your snippet.
                            As I said and hopefully made clear: Opacity is something very different.

                             

                            Uwe

                            • 11. Re: Find text Tint Value
                              tpk1982 Level 4

                              Hi Uwe,

                               

                              Yeah i forget to change those. Thanks for remember me.

                               

                              alert("Error: Check some text has Tint")


                              Regards,

                              Karthi