4 Replies Latest reply on Jan 3, 2015 1:52 AM by Teetan VK

    Add line count

    selvam214 Level 1

      Hi,

      I'm trying to get the kerning character's report from our document. I have done the script without the line count, can you please guide to me "how to add the line count with in this script".

       

      Screen shot 2015-01-02 at 5.26.04 PM.png

       

      //~ Define variables

      var myDoc = app.activeDocument;

      var myDocPath = myDoc.filePath;

      var myDocName = myDoc.name;

       

      Fnd = new Array();

      FoundContents = new Array();

      totalArray = new Array();

      try

      {

          var myColor = app.activeDocument.colors.item("KER").name;

          }

      catch(myError)

      {

          var myColor = app.activeDocument.colors.add();

          myColor.name = "URL";

          myColor. model = ColorModel.process;

          myColor.colorValue = [15, 100, 100, 0];

          }

      //~ End define variables

      //Array start for find urls and apply color

      var doc = app.activeDocument,

          _stories = doc.stories;

      for(var i=0;i<_stories.length;i++)

      {

              var characters = _stories[i].characters;

              for(var j=0;j<characters.length;j++)

              {

                      if(characters[j].insertionPoints[-1].kerningMethod != "Metrics" && characters[j].insertionPoints[-1].kerningMethod != "Optical")

                      {

                              if(characters[j].insertionPoints[-1].kerningValue <= -51)

                              {

                                      characters[j+1].fillColor = myColor;

                                      characters[j].fillColor = myColor;

                                  }

                          }

                  }

          }

      reportPage = new Array();

      reportContents = new Array();

      app.findTextPreferences = app.changeTextPreferences = null;

      app.findTextPreferences.fillColor = myColor;

      var myFoundColor = app.activeDocument.findText();

       

       

      for(f=0; f<myFoundColor.length; f++)

      {

          var myFoundPage =  myFoundColor[f].parentTextFrames[0].parentPage.name;

           Fnd.push(myFoundPage)

          var myFoundContents = myFoundColor[f].contents;

          FoundContents.push(myFoundPage + "\t" + myFoundContents + "\r")

          }

        • 1. Re: Add line count
          Jump_Over Level 5

          Hi,

           

          But which lines you want to count?

          All doc stories? Entire text on specific page? Just the lines detected as wrong kerning?

           

          Jarek

          • 2. Re: Add line count
            selvam214 Level 1

            Jarek,

             

            Just the lines detected as wrong kerning. The report as per below.

            Screen shot 2015-01-03 at 11.37.12 AM.png

            • 3. Re: Re: Add line count
              Chinnadk Level 4

              Try this,

               

              //~ Define variables
              var myDoc = app.activeDocument;
              var myDocPath = myDoc.filePath;
              var myDocName = myDoc.name;
              
              var result = [];
              try
              {
                  var myColor = app.activeDocument.colors.item("KER").name;
                  }
              catch(myError)
              {
                  var myColor = app.activeDocument.colors.add();
                  myColor.name = "URL";
                  myColor. model = ColorModel.process;
                  myColor.colorValue = [15, 100, 100, 0];
                  }
              //~ End define variables
              //Array start for find urls and apply color
              var doc = app.activeDocument,
                  _stories = doc.stories;
              for(var i=0;i<_stories.length;i++)
              {
                      var characters = _stories[i].characters;
                      for(var j=0;j<characters.length;j++)
                      {
                              if(characters[j].insertionPoints[-1].kerningMethod != "Metrics" && characters[j].insertionPoints[-1].kerningMethod != "Optical")
                              {
                                      if(characters[j].insertionPoints[-1].kerningValue <= -51)
                                      {
                                              characters[j+1].fillColor = myColor;
                                              characters[j].fillColor = myColor;
                                              result.push(characters[j].parentTextFrames[0].parentPage.name + "\t" + characters[j].parentStory.characters.itemByRange(characters[j].parentTextFrames[0].lines[0].index,  characters[j].index).lines.length + "\t"+ characters[j].contents + "\r")
                                          }
                                  }
                          }
                  }
              alert(result)
              
              

               

              Regards,

              Chinna

              • 4. Re: Add line count
                selvam214 Level 1

                Chinna,

                I can't merge with my script, so working fine for another method based on your guidance.

                 

                Thanks for all those effort.

                Selva

                • 5. Re: Add line count
                  Teetan VK Level 1

                  Could you please don't be so stupid

                  Whay don't you add a Non-joiner


                  ~j

                  between
                  ed

                  us

                  fi

                  di

                  c,

                  it

                  or set more bigger character kerning

                  Please! Please!