6 Replies Latest reply on May 12, 2014 1:27 AM by Laubender

    Please correct my Hyphenation setting script

    hasvi Level 1

      Hi,

       

      1. I want to set hyphenation=false for all the heading levels, That heading level details are saved in .txt file format. For instance 'Heading detail.txt' has heading level paragraph style names: H1, H2, BT, CT, CN.
      2. Otherwise if hyphenation=true in normal paragraph styles (like TX, EXT) I have to change the hyphenation setting. This one I have completed as like below script

       

       

      app.activeDocument.paragraphStyles.everyItem().properties={

          hyphenateWordsLongerThan:6,

          hyphenateAfterFirst:3,

          hyphenateBeforeLast:3,

          hyphenateLadderLimit:2,

          hyphenationZone:"1p",

          hyphenateCapitalizedWords:true,

          hyphenateLastWord:false,

          hyphenateAcrossColumns:false,

          }

      if(myPara[i].hyphenation=false)

       

      I want to implement the 1st point detail in my script, so please correct my script.

       

      Thanks

        • 1. Re: Please correct my Hyphenation setting script
          Chinnadk Level 4

          Hi Hasvi,

           

          Try the below method,

           

          var doc = app.activeDocument;

          var regex1=new RegExp("\\w*H1");

          var pstyles = doc.paragraphStyles.everyItem().name;

          try{

              for (var i=1;i<pstyles.length;i++)

              {

                  if(regex1.test(pstyles[i]))

                  {

                      var h1 = pstyles[i].match(regex1).toString();

                      doc.paragraphStyles.item(h1).hyphenation = false;

                      }

                  }

          }

          catch(e){}

           

          Regards,

          Chinna

          • 2. Re: Please correct my Hyphenation setting script
            hasvi Level 1

            Hi,

             

            Its working properly, but how can we get all the Heading levels like "H1, H2, H3, CT,...." in this script?

             

            thanks

            • 3. Re: Please correct my Hyphenation setting script
              hasvi Level 1

              Hi,

               

              I got the answer, its working

               

              var myDoc=app.activeDocument;

              var myStyle=new Array("H1","H2","H3");

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

              {

                      if(myDoc.paragraphStyles.item(myStyle[i]).isValid)

                      {

                       myDoc.paragraphStyles.item(myStyle[i]).hyphenation = false;

                      }

                  }

              alert("ok");

               

               

              But, any option for compare with txt file?

              1. I want to set hyphenation=false for all the heading levels, That heading level details are saved in .txt file format. For instance 'Heading detail.txt' has heading level paragraph style names: H1, H2, BT, CT, CN.

               

              thanks

              • 4. Re: Please correct my Hyphenation setting script
                Chinnadk Level 4

                Hi Hasvi,

                 

                Here it is.

                 

                var doc = app.activeDocument;

                var pstyles = doc.allParagraphStyles;

                var file = File('c:/1.txt');  //Style name should be separeted by ,(only comma not comma then space) in text file

                file.open('r');

                var content = file.read();

                for(var i=1;i<pstyles.length;i++){

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

                    {

                            if(pstyles[i].name == Split(content)[j])

                            {

                                    pstyles[i].hyphenation = false;

                                }

                        }

                }

                file.close();

                function Split(str) {

                    return str.split(',');

                }

                 

                Regards,

                Chinna

                • 5. Re: Please correct my Hyphenation setting script
                  hasvi Level 1

                  Hi Chinna,

                   

                  Brilliant thanks for your timing help, thank you again.

                   

                  by

                  hasvi

                  • 6. Re: Please correct my Hyphenation setting script
                    Laubender Adobe Community Professional & MVP

                    @Hasvi – so the 10 points should go to Chinna, don't you think ;-)

                     

                    Uwe