14 Replies Latest reply on Aug 19, 2017 9:52 AM by keyvanm97232351

    [018] Table + Overset Text in Cell! …

    Obi-wan Kenobi Adobe Community Professional

      Hi Scripters,

       

      Really dubitative! By contrariety, this code desperately refuses to work!! 

       

       

      var myDoc = app.activeDocument,
      myStories = myDoc.stories,
      myTables = myStories.everyItem().tables.everyItem().getElements();
      var T = myTables.length,
      t, C, c;
      
      
      delete_Overset();
      
      
      function delete_Overset() {    
          for ( t = 0; t < T; t++ ) {
              var myCells = myTables[t].cells.everyItem().getElements();
              C = myCells.length;
              for ( c = 0; c < C; c++) {
                  myOverflow = myCells[c].overflows;
                  while ( check_Overflow ( myOverflow ) == true ) {
                      myCells[c].paragraphs[0].desiredGlyphScaling -= 1;
                      myCells[c].paragraphs[0].desiredWordSpacing -= 1;
                  }
                  function check_Overflow ( myCellStory ) {
                      if ( myCellStory == true )
                      return true;
                      return false;
                  }
              }
          }
      }
      
      

       

       

      Thanks for your help!

       

      (^/) 

        • 1. Re: [018] Table + Overset Text in Cell! …
          Jump_Over Level 5

          Hi Obi,

           

          You cant set a desiredXXX value without relation to minimumXXX value.

           

          But even if you modify both - you set your preferences for Adobe Paragraph Composer rather than kill cell's overset.

          Wrong way

           

          Jarek

          • 2. Re: [018] Table + Overset Text in Cell! …
            Obi-wan Kenobi Adobe Community Professional

            Hi Jarek,

             

            The para style "Justification" settings are:

             

            Capture d’écran 2017-08-01 à 12.20.04.png

             

            After the script, the para settings becomes:

             

            Capture d’écran 2017-08-01 à 12.19.46.png

             

            Normally, in my sample [on the [only one] overset cell of the table], the script would have to stop at this moment:

             

            Capture d’écran 2017-08-01 à 12.26.35.png

             

            Why? 

             

            (^/)

            • 3. Re: [018] Table + Overset Text in Cell! …
              Jump_Over Level 5

              Hi,

               

              Would have to stop cause there is a space enough to fit?

              Maybe it need to be recomposed? I am not sure if Adobe Composer works 'on the fly' while script' job.

               

              Jarek

              1 person found this helpful
              • 4. Re: [018] Table + Overset Text in Cell! …
                Obi-wan Kenobi Adobe Community Professional

                Jarek [ Hi Jongware!  ],

                 

                This seems to work but not sure it's the more "orthodox" way to fix it! …

                 

                var myDoc = app.activeDocument,
                myStories = myDoc.stories,
                myCells = myStories.everyItem().tables.everyItem().cells.everyItem().getElements();
                var C = myCells.length, c;
                
                
                delete_Overset();
                
                
                function delete_Overset() {    
                    for ( c = 0; c < C; c++) {
                        var myOverflow = myCells[c].overflows;
                        while ( check_Overflow ( myOverflow ) == true ) {
                            try {
                                myCells[c].paragraphs[0].desiredGlyphScaling -= 1;
                                myCells[c].paragraphs[0].desiredWordSpacing -= 1;
                                myCells[c].recompose();
                                var myOverflow = myCells[c].overflows;
                                check_Overflow ( myOverflow );
                            } catch(e){}           
                        }
                        continue;
                            
                        function check_Overflow ( myCellStory ) {
                            if ( myCellStory == true ) return true;
                            return false;
                        }
                    }
                }
                

                 

                 

                At the beginning, I've 2 Tables with 3 oversets:

                 

                Capture d’écran 2017-08-01 à 14.42.25.png

                 

                Result after Script: 3 different "Justification" settings [could play with tracking/scaling too]:

                 

                Capture d’écran 2017-08-01 à 14.43.13.png

                Capture d’écran 2017-08-01 à 14.43.34.png

                Capture d’écran 2017-08-01 à 14.43.52.png

                 

                I will really appreciate your comments! 

                 

                (^/)

                • 5. Re: [018] Table + Overset Text in Cell! …
                  Loic.Aigon Adobe Community Professional

                  Hi Obi,

                   

                  There could be so many issues here but a wild guess would be that using -= 1 in your case doesn't really help. The -= operator helps modifying numerical value but imho that wouldn't work when it comes to assigning a new property value. Or rather you may change the value of desiredGlyphScaling but not the property itself.

                   

                  Here is a possible approach:

                   

                   

                  
                  var main = function() {
                  var doc = app.properties.activeDocument,
                  cells, n, nCell, para1;
                  
                  
                  if ( !doc ) return;
                  
                  cells = doc.stories.everyItem().tables.everyItem().cells.everyItem().getElements();
                  n = cells.length;
                  
                  while ( n-- ) {
                  nCell  = cells[n];
                  if ( nCell.overflows ) {
                  para1 = nCell.paragraphs[0];
                  var newGlyphScaling = para1.desiredGlyphScaling;
                  var newWordSpacing = para1.desiredWordSpacing;
                  
                  para1.properties = {
                  minimumGlyphScaling : (newGlyphScaling-1<para1.minimumGlyphScaling)? newGlyphScaling-1 : para1.minimumGlyphScaling,
                  desiredGlyphScaling : newGlyphScaling-1,
                  desiredWordSpacing : newWordSpacing-1
                  }
                  };
                  }
                  
                  }
                  
                  
                  var u;
                  
                  
                  app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "The Script" );
                  
                  • 6. Re: [018] Table + Overset Text in Cell! …
                    Obi-wan Kenobi Adobe Community Professional

                    Thanks a lot, Loïc,

                     

                    Always nice to have another approach and other kinds of writing. Especially for my learning. 

                     

                    Something is missing in your code:

                    In the "if ( nCell.overflows ) { … }", you need to check if, after the first treatment, the cell is always or not "overflow"!

                     

                    Capture d’écran 2017-08-01 à 21.38.24.png

                     

                    Capture d’écran 2017-08-01 à 21.37.45.png

                     

                    If you can correct this part, it would be cool!  Thanks in advance! 

                     

                    (^/)

                    • 7. Re: [018] Table + Overset Text in Cell! …
                      Loic.Aigon Adobe Community Professional

                      Just replace if by while. A bit risky tough.

                      • 8. Re: [018] Table + Overset Text in Cell! …
                        Obi-wan Kenobi Adobe Community Professional

                        That doesn't work!

                         

                        (^/)

                        • 9. Re: [018] Table + Overset Text in Cell! …
                          [Jongware] Most Valuable Participant

                          Obi-1, I believe Jarek is right because I have had similar problems with manipulating tables. You have to imagine what happens in the background: a script is running in one thread, and in another one InDesign is promoting the changes into the actual document. The odd recompose() forces the script to wait while the typesetter is catching up.

                          • 10. Re: [018] Table + Overset Text in Cell! …
                            Obi-wan Kenobi Adobe Community Professional

                            Jongware,

                             

                            Could you develop? Too hard to understand for me! 

                             

                            (^/)

                            • 11. Re: [018] Table + Overset Text in Cell! …
                              Loic.Aigon Adobe Community Professional

                              Hi,

                              Undependantly of composer's concerns, just to give the snippet an end :

                              
                              var main = function() {
                              var doc = app.properties.activeDocument,
                              cells, n, nCell, para1, newGlyphScaling, newWordSpacing;
                              
                              
                              if ( !doc ) return;
                              
                              cells = doc.stories.everyItem().tables.everyItem().cells.everyItem().getElements();
                              n = cells.length;
                              
                              while ( n-- ) {
                              nCell  = cells[n];
                              while ( nCell.overflows ) {
                              para1 = nCell.paragraphs[0];
                              newGlyphScaling = para1.desiredGlyphScaling-1;
                              newWordSpacing = para1.desiredWordSpacing-1;
                              
                              if ( newWordSpacing<50 || newWordSpacing<0 ) break;
                              
                              para1.properties = {
                              minimumGlyphScaling : (newGlyphScaling<para1.minimumGlyphScaling)? newGlyphScaling : para1.minimumGlyphScaling,
                              desiredGlyphScaling : newGlyphScaling,
                              minimumWordSpacing : (newWordSpacing<para1.minimumWordSpacing)? newWordSpacing : para1.minimumWordSpacing,
                              desiredWordSpacing : newWordSpacing
                              }
                              };
                              }
                              
                              }
                              
                              
                              var u;
                              
                              
                              app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "The Script" );
                              
                              • 12. Re: [018] Table + Overset Text in Cell! …
                                Obi-wan Kenobi Adobe Community Professional

                                Loïc,

                                 

                                Still not!

                                 

                                This one works:

                                 

                                var main = function() {
                                    
                                    var doc = app.properties.activeDocument,  
                                    cells, n, nCell, myOverflow, para1, newGlyphScaling, newWordSpacing;  
                                      
                                    if ( !doc ) return;  
                                      
                                    cells = doc.stories.everyItem().tables.everyItem().cells.everyItem().getElements();  
                                    n = cells.length;  
                                      
                                    while ( n-- ) {  
                                        nCell  = cells[n],
                                        myOverflow = nCell.overflows;
                                
                                
                                        while ( myOverflow ) {  
                                            para1 = nCell.paragraphs[0];  
                                            newGlyphScaling = para1.desiredGlyphScaling-1;  
                                            newWordSpacing = para1.desiredWordSpacing-1;  
                                              
                                            if ( newWordSpacing<50 || newWordSpacing<0 ) break;  
                                              
                                            para1.properties = {  
                                            minimumGlyphScaling : (newGlyphScaling<para1.minimumGlyphScaling)? newGlyphScaling : para1.minimumGlyphScaling,  
                                            desiredGlyphScaling : newGlyphScaling,  
                                            minimumWordSpacing : (newWordSpacing<para1.minimumWordSpacing)? newWordSpacing : para1.minimumWordSpacing,  
                                            desiredWordSpacing : newWordSpacing  
                                            }
                                    
                                        nCell.recompose();
                                        var myOverflow = nCell.overflows;
                                
                                
                                        }
                                    }  
                                  
                                }  
                                
                                
                                var u;  
                                  
                                app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "The Script" );  
                                

                                 

                                 

                                (^/)

                                1 person found this helpful
                                • 13. Re: [018] Table + Overset Text in Cell! …
                                  Loic.Aigon Adobe Community Professional

                                  Yes i realized after i did forget to recompose the paragraph but you get the idea

                                  • 14. Re: [018] Table + Overset Text in Cell! …
                                    keyvanm97232351

                                    Hi

                                    Why not just change the characters horizontal scale instead of paragraph justification properties?