9 Replies Latest reply on Apr 7, 2016 5:08 AM by karthiks94217840

    Please Help me...For loose line fixer

    tpk1982 Level 4



      I just want to try a script for fixing loose lines automatically. My concept is,


      1) Finding the wrod space width.


      2) Depending on the width value, fix desired width value. I know it may vary for each character and fonts.


      3) If finding any over widthed space inside the para, i need to give tracking from value -1 to -10 untill we reached desired width. If not possible retain to zero tracking(original state). We don't need to check this for single line para, so just skip that.


      My client SOP:


      1) H&J values should not changes.


      2) Single line composer alone used


      3) Single line tracking not used.


      4) Positive tracking not allowed


      5) Tracking value should between -1 to -10.


      Is it possible?


      Thanks in Advance.

        • 1. Re: Please Help me...For loose line fixer
          tpk1982 Level 4

          Is there any updates for my question? I am stunned to do this via scripting!!! pls help me...

          • 2. Re: Please Help me...For loose line fixer
            John Hawkinson Level 5

            Yes, it's possible. Or at least, theoretically ,it might not end up fitting your copy.


            Please ask a small and specific question though. It'd be a fairly complicated script overall, so tell us what particular point you are stuck on, and we'll help you from there.

            • 3. Re: Please Help me...For loose line fixer
              Fred Goldman Level 3

              What is wrong with InDesign's built in justification settings? It allows you to set minimum and maximums for letter spacing which is the same thing as tracking.

              • 4. Re: Please Help me...For loose line fixer
                tpk1982 Level 4

                Hi All,


                I am not expert in script. So i dont know how to start.


                I can't violate the justification setting. My client does not allow me to do this.


                As both of you are experts in Scripting, it is easy task for you to write the codings. I just seek your help.

                • 5. Re: Please Help me...URGENT
                  tpk1982 Level 4

                  Hi ,


                  My friend gave me a little script to find space width of paragraph.


                  //Setting preferences to point and


                  //set page rulers to pageOrigin


                  var myDoc = app.activeDocument;


                  myDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;


                  myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;


                  myDoc.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;


                  myDoc.zeroPoint = [0, 0];


                  var docStories = myDoc.stories;


                  for (var st=0; st<docStories.length; st++){


                      var paras = docStories[st].paragraphs;




                      for (var p=0; p<paras.length; p++){


                          if (paras[p].lines.length>1){


                              app.findGrepPreferences.findWhat = " ";//Find All spaces in current paragraph


                              var spaces = paras[p].findGrep();


                              if (spaces.length>0){


                                  spaceWidth = spaces[0].endHorizontalOffset-spaces[0].horizontalOffset;//end position - start position gives the width of the space character


                                  alert("Paragraph "+(p+1)+" Space Width = "+spaceWidth);




                              }//End of if loop lines >1


                          }//End  of "p" for loop


                      }//End of stories for loop



                  function ClearGrepPreferences(){

                      app.findGrepPreferences = NothingEnum.NOTHING;
                      app.changeGrepPreferences = NothingEnum.NOTHING;
                      app.findTextPreferences = NothingEnum.NOTHING
                      app.changeTextPreferences = NothingEnum.NOTHING




                  From this script, i want to find the average space width of entire document (it actually find the space of each para). It will saved in the variable  spaceWidth. Then the script ask user for giving a desired space width. Let say, userSpace. Then it will compare the userSpace with   spaceWidth. If the space Width is more than userSpace value,  then allow tracking from -1 to -10 using FOR loop to get desired value. If it will not get desired then retain the para tracking as zero and skip to next para.


                  Am i get any help from this point?


                  Advance thanks

                  • 6. Re: Please Help me...For loose line fixer
                    karthiks94217840 Level 2

                    Hi tpk1982


                    I need your help tpk.


                    I was try to script based on the your above script and same requirement also. You have completed that script coding? Please advice Tpk.


                    Please suggest how to completed this task.


                    Advance Thanks.

                    • 7. Re: Please Help me...For loose line fixer
                      karthiks94217840 Level 2

                      Dear Java expert


                      Please suggest friend for above my question? advice me



                      • 8. Re: Please Help me...For loose line fixer
                        tpk1982 Level 4



                        I dropped the script, because the spacing is depend upon font style, justification and kerning. It may be different. Not sure it worked

                        • 9. Re: Please Help me...For loose line fixer
                          karthiks94217840 Level 2

                          Hi tpk1982




                          Good explain,


                          Thanks tpk1982