10 Replies Latest reply on Apr 20, 2017 12:59 PM by bsf2017

    Hyphenation off in Tables

    littlemookie Level 1

      Hi All,

       

      I have a script that will turn off hyphenation throughout a document:

       

      for (var i=app.activeDocument.stories.length-1; i>=0; i--)
      {
      for (var j=app.activeDocument.stories[i].paragraphs.length-1; j>=0; j--)
        app.activeDocument.stories[i].paragraphs[j].hyphenation = false;
      }

       

      However, it doesn't catch the text within tables, is there a way of altering the script or creating a seperate script to accomodate tables?

       

      Cheers,

       

      LMookie

        • 1. Re: Hyphenation off in Tables
          Kasyan Servetsky Level 5

          var myDoc = app.activeDocument;
          for (var i=myDoc.stories.length-1; i>=0; i--) {
              var myStory = myDoc.stories[i];
              for (var j=myStory.paragraphs.length-1; j>=0; j--) {
                  myStory.paragraphs[j].hyphenation = false;
              }
              if (myStory.tables.length > 0) {
                  for (k=0; k<myStory.tables.length; k++) {
                      var myTable = myStory.tables[k];
                      for (c=0; c<myTable.cells.length; c++) {
                          var myCell = myTable.cells[c];
                          for (p=myCell.paragraphs.length-1; p >= 0; p--) {
                              myCell.paragraphs[p].hyphenation = false;
                          }
                      }
                  }
              }
          }

           

          alert("Done");

          • 2. Re: Hyphenation off in Tables
            [Jongware] Most Valuable Participant

            This works as well:

             

            app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().paragraphs.eve ryItem().hyphenation = false;

            • 3. Re: Hyphenation off in Tables
              Kasyan Servetsky Level 5

              Yes, and its much shorter as well.

              • 4. Re: Hyphenation off in Tables
                [Jongware] Most Valuable Participant

                ... except for that space in "para graphs" -- that shouldn't have been there!!

                 

                (I blaim the forum for that.)

                • 5. Re: Hyphenation off in Tables
                  bsf2017

                  I have tried this code but it does not seem to change my hyphenation. I am using InDesign CS6. Is there something different I need to use for CS 6?

                   

                   

                  app.activeDocument.stories.everyItem().texts.everyItem().hyphenation=false;

                   

                  myTables = app.activeDocument.stories.everyItem().tables.everyItem();

                  myTables.cells.everyItem().paragraphs.everyItem().hyphenation=false;

                  • 6. Re: Hyphenation off in Tables
                    Laubender Adobe Community Professional & MVP

                    Hi,

                    your code should work.

                    Select some text and see if hyphenation is checked with your Paragraph panel.
                    It should be off.

                     

                    In case it does not try this one:

                     

                    app.activeDocument.stories.everyItem().
                    texts.everyItem().hyphenation = false;
                    
                    app.activeDocument.stories.everyItem().
                    tables.everyItem().cells.everyItem().
                    texts.everyItem().hyphenation = false;
                    

                     

                    FWIW: Turning off hyphenation could create permanent overflow of text frames and text cells.

                     

                    Regards,
                    Uwe

                    • 7. Re: Hyphenation off in Tables
                      bsf2017 Level 1

                      Great. The script now turns off hyphenation. The reason I thought it didn't was the the style has not been modified, so when you open the style window, hyphenation is still checked.

                      Can I redefine all styles to include the turned off hyphenation?

                      The StyleOverriden property does not work.

                      Is there a list anywhere, which properties and methods are available for paragraphStyles? I have checked the InDesign Scripting guide but there is no list of methods or properties for ParagraphStyles.

                       

                      Thanks

                      B

                       

                       

                      function styleRedefine(){

                       

                          for(var myCounter = myDoc.paragraphStyles.length - 1; myCounter > 0; myCounter--){

                              if (myDoc.paragraphStyles[myCounter].styleOverriden == true) {

                                  var myParProperties = myDoc.paragraphStyles[myCounter].properties;

                                  myDoc.paragraphStyles[myCounter].remove();

                                  var myNewParStyle = myDoc.paragraphStyles.add();

                                  myNewParStyle.properties = myParProperties;

                              }

                          }

                      • 8. Re: Hyphenation off in Tables
                        bsf2017 Level 1

                        actually, by trial and error I figured it out:

                         

                        myNewParStyle.hyphenation = false;

                         

                        • 9. Re: Hyphenation off in Tables
                          Laubender Adobe Community Professional & MVP

                          For DOM documentation see:

                           

                          Jongware:

                          Indesign JavaScript Help

                           

                          Gregor Fellenz:

                          InDesign ExtendScript API (12.0)
                          Index of /extendscriptAPI

                           

                          Gregor also provided this if you want to create your own:
                          GitHub - grefel/extendscriptApiDocTransformations: Transformations for Adobe ExtendScript API Documentation

                           

                          Why creating your own?
                          Because some versions of InDesign are not covered by Jongware or Gregor. InDesign CC version 9 for example.
                          Because there are differences between dot versions. 11.0 ≠ 11.4 , 12.0 ≠ 12.1 etc.pp.

                          Because you installed some scriptable 3rd party plug-ins or additional Adobe plug-ins like the old DPS functionality.

                           

                          Regards,
                          Uwe

                          • 10. Re: Hyphenation off in Tables
                            bsf2017 Level 1

                            Apparently when I redefine the styles, the whole document looses it's applied styles.

                            Can I store the appliedParagraphStyles in a variable

                            then redefine the styles

                            then reapply the styles from the stored variable?

                             

                            something like:

                             

                             

                            for (var i = 1; myDoc.stories.everyItem.paragraphs.everyItem().count; i++){

                             

                                    style(i) = myDoc.stories.everyItem.paragraph(i).appliedParagraphstyle;

                                }

                            redefinestyle

                             

                            for (var i = 1; myDoc.stories.everyItem.paragraphs.everyItem().count; i++){

                             

                                    myDoc.stories.everyItem.paragraph(i).appliedParagraphstyle = style(i);

                                }

                             

                            ??

                            Thanks