23 Replies Latest reply on May 28, 2015 10:26 PM by selvam214

    Select texts based on the 'Customer tracking/Kerning' option

    selvam214 Level 1

      Hi All,

      If it possible to push all the tracking/Kerning texts to the array? If it possible to attack with highlighted text as per below?

      Screen shot 2015-05-05 at 5.11.34 PM.png

       

      Screen shot 2015-05-05 at 5.12.36 PM.png

        • 1. Re: Select texts based on the 'Customer tracking/Kerning' option
          Daniel Sterchi Adobe Community Professional

          Hi Selvam214

           

          What exactly do you want to do?

          What do you want to achieve?

           

          It is quite simple to move the highlighted Text to an array. What is the purpose to move it to an array?

           

          kind regards

           

          Daniel (from Switzerland)

          • 2. Re: Select texts based on the 'Customer tracking/Kerning' option
            selvam214 Level 1

            Hi Daniel,

            Thanks for the inquiry. Here is my goal.

             

            1. I have a document with 3000 pages (plain text without linked frames)

            2. I need to apply the red color above kerningValues = -100 (text)

             

            Issue: If, we need to check each and every character's kerning values, take much time to get the result. Some time we can't get the result.

             

            So, we directly to catch the highlighted text and move to the array, then validate those texts (array text only) and apply the colors. If it possible this method?

             

            Thanks,

            Selva

            • 3. Re: Select texts based on the 'Customer tracking/Kerning' option
              Laubender Adobe Community Professional & MVP

              selvam214 wrote:

              Issue: If, we need to check each and every character's kerning values, take much time to get the result. Some time we can't get the result.

               

              Hi Selva,

              do you have any idea why you cannot get the result?

               

              Uwe

              • 4. Re: Select texts based on the 'Customer tracking/Kerning' option
                Daniel Sterchi Adobe Community Professional

                Pardon me but I don't get the reason why you want to move text into an array.

                Do you want to move the whole selected text into one element and what do you want to do with the text in the array?

                 

                Do you want to apply a character style to the characters/words with kerning values -100?

                In the title it says tracking/kerning do you also want to do something to the text which has tracking?

                 

                Is the plan to select the whole text from one page, since the text frames are not linked together?

                 

                I am sorry to ask you so many questions. With the answers I hope to provide you with some code snippets.

                 

                kind regards

                 

                Daniel (from Switzerland)

                • 5. Re: Select texts based on the 'Customer tracking/Kerning' option
                  selvam214 Level 1

                  Hi Uwe,

                  May be too much characters, 1 lakh (one hundred thousand)  and above.

                   

                  Selva

                  • 6. Re: Select texts based on the 'Customer tracking/Kerning' option
                    selvam214 Level 1

                    Hi Daniel,

                    Here is my reply in RED.

                     

                    Version:1.0 StartHTML:0000000105 EndHTML:0000004289 StartFragment:0000002456 EndFragment:0000004253    

                    Pardon me but I don't get the reason why you want to move text into an array.

                    The reason why, move these texts into an array, if less content (compare with full book) simple to find the kerning values and apply the color (limited text only, then we need to check easily).

                    Do you want to move the whole selected text into one element and what do you want to do with the text in the array?

                    Once moved the limited text, then we find the kerning value.

                     

                    Do you want to apply a character style to the characters/words with kerning values -100?

                    Yes, after that, I’ll get the report from this document and move to xml process for merged characters lists

                     

                    In the title it says tracking/kerning do you also want to do something to the text which has tracking?

                    Yes, I’ll apply the color.

                     

                    Is the plan to select the whole text from one page, since the text frames are not linked together?

                    Yes, finally I need the merged character report from this document. May you please correct me, if I’m follow any wrong process.

                     

                    I am sorry to ask you so many questions. With the answers I hope to provide you with some code snippets.

                    No problem, you are helping me, this is always welcome.

                     

                    Selva

                    • 7. Re: Select texts based on the 'Customer tracking/Kerning' option
                      Daniel Sterchi Adobe Community Professional

                      So I put together a few lines.

                       

                      Try them and tell me if this points in the right direction.

                       

                      To use the Script you need a InDesign-file with text. Some of the characters should have kerning (-100). On top you need a character style in the InDesign-dokument with the name «red». If you change the color in the character style you should see that the characters with kerning (-100) have the given color after you run the script.

                       

                      kind regards

                       

                      Daniel (from Switzerland)

                       

                      main();
                      exit();
                      
                      function main() {
                         
                          // if there is an open document in InDesign
                          if (app.documents.length > 0) {
                              var myDoc = app.activeDocument;
                         
                              // get the selected text
                              var mySel = myDoc.selection[0];
                         
                              if ((mySel != null) && (mySel.constructor.name == "Text")) {
                                 
                                  // create an array
                                  var charArray = new Array();
                                  alert("information \nText selected");
                             
                                  alert("Information\n# characters selected: " + mySel.characters.length);
                             
                                  for (var i = 0; i < mySel.characters.length; i++) {
                                      var myChar = mySel.characters[i];
                                     
                                      // if the kerning was changed
                                      if (myChar.kerningMethod == "Manual") {
                                         
                                          // output to the console
                                          $.write("Character: >" + myChar.contents + "< kerning: " + myChar.kerningValue);
                      
                                          // if the kerning is -100 or  less
                                          if (myChar.kerningValue < -99) {
                                             
                                              // apply characterstyle to found characters no array needed
                                              myChar.appliedCharacterStyle = myDoc.characterStyles.item("red");
                                              $.writeln(" OK got it");
                      
                      
                                              // push character into array
                                              charArray.push(myChar);                       
                                          }
                                          else $.writeln();
                                      }
                                  }
                                  alert("Information\nCharacters with kernig -199 found: " + charArray.length);
                              }
                              else alert("Warning\nNoting or no text selected");
                          }
                          else alert("Warning\nno document open");
                         
                          alert("Information\nI did my job, what about yours?");
                      }
                      
                      • 8. Re: Select texts based on the 'Customer tracking/Kerning' option
                        selvam214 Level 1

                        Hi Daniel,

                        Thanks for this.

                         

                        FYI... Now running this tool, I can't get the result till now (392618 characters / running time 1 hour and above), so i'm waiting.

                         

                         

                        Selva.

                        • 9. Re: Select texts based on the 'Customer tracking/Kerning' option
                          selvam214 Level 1

                          Hi Denial,

                          I'm sorry to say, still i'm waiting for the result.

                           

                          Selva.

                          • 10. Re: Select texts based on the 'Customer tracking/Kerning' option
                            Peter Kahrel Adobe Community Professional & MVP

                            Daniel, Selva,

                             

                            See this post: Re: Catch the kerning value for the reason why lines such as

                             

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


                            can make a script slow.


                            Peter

                            • 11. Re: Select texts based on the 'Customer tracking/Kerning' option
                              selvam214 Level 1

                              Hi Denial,

                              Yes, I got it . Really use full for this method (except the time saving).

                               

                              Thanks you so much your analyze and effort.

                               

                               

                               

                              I need one additional feature, collect all text without selection? Because I have more unlinked text frames in our document, especially they have used separate footnotes without the footnote links. Kindly do the needful.

                               

                              Sample here:

                              Screen shot 2015-05-07 at 8.00.09 PM.png

                              • 12. Re: Select texts based on the 'Customer tracking/Kerning' option
                                selvam214 Level 1

                                Yes Peter,

                                But, I can't get the final result from this discussion (multi frame-unlinked text frame not gather this tool). That's only I trying to approach to the different way about this topic. Can you please help for this.

                                 

                                 

                                Selva.

                                • 13. Re: Select texts based on the 'Customer tracking/Kerning' option
                                  Daniel Sterchi Adobe Community Professional

                                  Hi Peter

                                   

                                  You are right. A for-loop is very slow. I didn't think that the script is put to work with a huge text right away.

                                  The only thing I wanted to show is, that it is possible to do the task.

                                   

                                  When I look at the other thread I see that almost the same question is answered twice now.

                                   

                                  kind regards

                                   

                                  Daniel (from Switzerland)

                                  • 14. Re: Select texts based on the 'Customer tracking/Kerning' option
                                    Peter Kahrel Adobe Community Professional & MVP

                                    Daniel,

                                     

                                    It's not because of the for-loop, but because in

                                     

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


                                    you force InDesign to recreate the collection of characters, which is time consuming. Better first to create an array of characters using everyItem().getElements() and process that. That's the general idea, though Dirk, Marc, and Harbs in that thread suggested more improvements.


                                    Peter

                                    • 15. Re: Select texts based on the 'Customer tracking/Kerning' option
                                      Daniel Sterchi Adobe Community Professional

                                      Peter,

                                       

                                      Thanks for the hint!

                                      I didn't know that. So I changed the code from

                                       

                                                  for (var i = 0; i < mySel.characters.length; i++) { 
                                                      var myChar = mySel.characters[i];
                                      

                                       

                                      to

                                       

                                                  var myChars = mySel.characters.everyItem().getElements();
                                                  for (var i = 0; i < myChars.length; i++) {
                                                      var myChar = myChars[i];
                                      

                                       

                                      The second version was 10 times faster!

                                       

                                      kind regards

                                       

                                      Daniel (from Switzerland)

                                      • 16. Re: Select texts based on the 'Customer tracking/Kerning' option
                                        selvam214 Level 1

                                        Hi Daniel,

                                        After changed these lines, the application quite unexpectedly. But the sample pages got the result immediately (3 pages).

                                         

                                        Can I change the line as per below?

                                         

                                        from

                                        var mySel = myDoc.selection[0];

                                        to

                                        var mySel = myDoc.stories;



                                        or you have any other method.


                                        Because I need to validate all the texts in the current document. No need to selection text only.


                                        Selva.


                                        • 17. Re: Select texts based on the 'Customer tracking/Kerning' option
                                          Laubender Adobe Community Professional & MVP

                                          Hi Daniel,

                                          even with using getElements() a script calculating all single characters of a large document can be very, very slow.

                                          I had cases where getElements() was taking some minutes to gather all the characters in a large document.

                                           

                                          Note:

                                          app.documents[0].stories.everyItem().characters.everyItem().getElements();
                                          

                                           

                                          is doing its job, but not for text in footnotes and text in table cells.

                                           

                                          For that you need to do a second run for footnotes and a third run for tables and all cells.

                                          If nested tables are present (tables inside of cells) you best will do a Text Search for the special character representing a Table object.

                                          But this would require a for loop on the found special characters.

                                           

                                          Uwe

                                          • 18. Re: Select texts based on the 'Customer tracking/Kerning' option
                                            Daniel Sterchi Adobe Community Professional

                                            Hi Uwe

                                             

                                            Thank you for the Hint.

                                            It is clear to me that you have to tackle footnote and tables and nesting tables separately.

                                             

                                            So I tried to help and now I learned a lot. Great!

                                             

                                            I'll test that this evening, when I have more time. I'm curious how much faster the script will be with your code.

                                             

                                            kind regards

                                             

                                            Daniel (from Switzerland)

                                            • 19. Re: Select texts based on the 'Customer tracking/Kerning' option
                                              Laubender Adobe Community Professional & MVP

                                              Checking memory consumption could be also possible and one can act upon it…

                                              Closing all unused apps running concurrently…

                                              Using the right InDesign version, using the right machine for that particular task.

                                               

                                              On larger documents with text frames not threaded, it could also be a good strategy to use a GREP search for single characters, iterating through the spreads and saving the document often (with Save As perhaps), closing and opening them again more times to free memory. Or even do quit the app itself and restarting by means of an Apple Script on Macs (VBScript on Windows) to free memory.

                                               

                                              Just some suggestions for large InDesign documents with complex structures (large tables, large numbers of large tables).

                                               

                                              However, testing all this will consume a lot of time to find the right startegy speedwise for a particular document.

                                               

                                              Uwe

                                              • 20. Re: Select texts based on the 'Customer tracking/Kerning' option
                                                Laubender Adobe Community Professional & MVP

                                                And then there is InDesign Server as well…

                                                 

                                                Uwe

                                                • 21. Re: Select texts based on the 'Customer tracking/Kerning' option
                                                  selvam214 Level 1

                                                  Hi Uwe,

                                                  I will check one by one and get back to the result.

                                                   

                                                  I'm really happy for this conversation (with both), thank you very much for your knowledge sharing.

                                                   

                                                  Selva.

                                                  • 22. Re: Select texts based on the 'Customer tracking/Kerning' option
                                                    selvam214 Level 1

                                                    Hi All,

                                                    I got an idea to approach the kerning characters as per below. Can you please confirm, this is possible or not?

                                                     

                                                    Need to check the Preflight report and select those occurrences, then we need to check the kerning values from the selected occurrences (464 only).

                                                    Screen shot 2015-05-26 at 5.05.26 PM.png

                                                     

                                                    Kindly let me know if i'm wrong.

                                                     

                                                    Selva

                                                    • 23. Re: Select texts based on the 'Customer tracking/Kerning' option
                                                      selvam214 Level 1

                                                      Hi All,

                                                      If it possible to approach the preflight report with the javascript?

                                                       

                                                       

                                                       

                                                       

                                                       

                                                       

                                                      Selva,

                                                      (sorry to say for the interrupting to all. I need a solution for this. That's only I checking once again).