7 Replies Latest reply on Jul 14, 2016 10:45 AM by mechaichezilla

    Detect Overset in Cell and/or Force Wrap

    mechaichezilla

      Hi,

       

      I'm not sure if I'm using the correct wording, but here's the problem:

       

      We have table cells that contain overset text, but cell.overflows doesn't work here, so my guess is that overflows behaves differently than overset.

       

      Basically what I'm trying to do is, to show the content of the cell, no matter if it is too wide (it's some long cryptic codes, that don't seem to wrap at all), so maybe the overset detection is not necessary, if there is an easier way to always show the content. The cell can change in height, but not in width, this works fine for regular text, that is wrapped automatically. But these codes do not get wrapped.

       

      Any ideas on how to force the text to show?

       

      Thanks a lot

        • 1. Re: Detect Overset in Cell and/or Force Wrap
          Laubender Adobe Community Professional & MVP

          Could you show a screenshot where an overflowing text cell is showing and no overset is indicated?


          Lately I ran into something like that with merged cells and edited text:

           

          TextWillFlowOutOfTheCell.png

           

          You could calculate the height of the cell and the horizontal offset of the first and the last line of the cell to see if the contents would be problematic.

           

          Regards,
          Uwe

          • 2. Re: Detect Overset in Cell and/or Force Wrap
            mechaichezilla Level 1

            Hi,

             

            thanks for the reply. I guess measuring the text will not help, since we don't want to apply any changes to it. Here's our situation:

            ind_cell_1.PNG ind_cell_2.PNG

            In the first picture, you can see the result of our script and in the second one the content after I adjusted the width manually. What InDesign does with the WAAT+OVFX and WAAS+OVFX content is what I would like to get in the WAAF+43FT cell as well. But it seems that the WAAF+43FT-code is not suitable for wrapping.

             

            The generated document is used as preview-pdf of the document for some people without access ti InDesign who just check the data, so it does not have to look perfect, but we need to show everything in the document. The final design steps will be applied manually anyway, since we don't expect to produce perfect documents automatically. But in the preview-version, no content should be hidden, no matter how bad it looks.

             

            Thanks again

            • 3. Re: Detect Overset in Cell and/or Force Wrap
              Laubender Adobe Community Professional & MVP

              So your problem is quite different to mine where the text literally is overflowing the bottom bounds of the cell.

               

              I don't get why you said "cell.overflows doesn't work here".
              Select the cell that has the red dot indicating overset and run this ExtendScript snippet:

               

              alert( app.selection[0].overflows );
              

               

              You should get a true

              in return.

               

              And that would be the first corner stone to write a script, that would change the width of the column so that the text could fit in without oversetting the cell.

              I don't know enough of your project to give any hints what's appropriate and what's not when it comes to formatting the text in your table. But what could help is setting the language of the text to "[No Language]".

               

              Regards,
              Uwe

              • 4. Re: Detect Overset in Cell and/or Force Wrap
                mechaichezilla Level 1

                Hmm, that's strange. If I use your script in the finished document, I get 'true' for each cell that overflows, but while the script is running, only on a few cells return true. For example, I have one row where 8 cells overflow, but only one of them returns true, while the script is running.

                 

                This solution would be fine for me, but it needs the overflow check to work:

                 

                If a cell returns true, I rotate the text by 90° and adjust the row height until it fits. But unfortunately, most overflow cells don't return true. Cell styles and paragraph styles have already been applied before I check for overflow. Is there another element inside the cell I could check for overflow that works more accurately? Or could it be a timing problem? Maybe a sleep timer would work here?

                 

                Thanks again

                 

                Edit:

                 

                Yes, it was a timing problem. I just set a sleep-timer of 200ms and it works just fine. It's just quite slow now. If you have any idea how to solve this without the sleep timer, that would be great, otherwise I'll mark this as solved and we need to be a little patient while the script is running .

                • 5. Re: Detect Overset in Cell and/or Force Wrap
                  tpk1982 Level 4

                  Hope the below will give the alert if overset present in the document

                   

                  if(app.activeDocument.stories.everyItem().tables.everyItem().columns.everyItem().cells.everyItem().overflows.join().indexOf('true' )!=-1)
                      alert("Overset found in table");
                  

                   

                   

                  then we can use table width extension code until the above condition gets false

                  • 6. Re: Detect Overset in Cell and/or Force Wrap
                    Laubender Adobe Community Professional & MVP

                    mechaichezilla wrote:

                     

                    … If a cell returns true, I rotate the text by 90° and adjust the row height until it fits. But unfortunately, most overflow cells don't return true. …

                     

                    Yes, it was a timing problem. I just set a sleep-timer of 200ms and it works just fine. It's just quite slow now. If you have any idea how to solve this without the sleep timer, that would be great, otherwise I'll mark this as solved and we need to be a little patient while the script is running .

                    Alright. Cool trick. In what stage of your script do you set the sleep-timer?
                    Maybe it would also help to use the method recompose() on the cells, the table, the story or the whole document?


                    Hm. To do a recomposition of all elements in a document would require an export to IDML, opening the IDML and saving the document. But this also comes with a huge penalty on performance.

                     

                    Regards,
                    Uwe

                    • 7. Re: Detect Overset in Cell and/or Force Wrap
                      mechaichezilla Level 1

                      Laubender schrieb:

                       

                      Alright. Cool trick. In what stage of your script do you set the sleep-timer?

                      The sleep timer is set directly after the row has been created for each cell that has been filled. But only for cells that are in danger of overflowing, otherwise it would probably take too long.

                       

                      But the workaround is OK for now, so I marked it as answered.

                       

                      Thanks again, without theck overflow check in the final document I wouldn't have figured it out.