4 Replies Latest reply on Feb 11, 2012 8:32 AM by winterm

    Find TextFrame Empty

    JesRoberts

      Hi All,

       

      How to find whether a TextFrame is empty or not..

       

      Thanks & Regards,

      Ramya A

        • 1. Re: Find TextFrame Empty
          winterm Level 4

          Hi,

          what exactly you are going to do with found empty text frame?

          well, while waiting for REAL scripters to come...

          literally, this JS code finds and selects first occurence of such item in a document:

           

           

          var myStories = app.activeDocument.stories.everyItem().getElements();
          for (i = myStories.length - 1; i >= 0; i--){
              var myTextFrames = myStories[i].textContainers;
              for (j = myTextFrames.length - 1; j >= 0; j--)    {
                  if (myTextFrames[j].contents == ""){
                      myTextFrames[j].select();
                  }
              }
          }
          
          1 person found this helpful
          • 2. Re: Find TextFrame Empty
            Laubender Adobe Community Professional & MVP

            @winterm – unfortunatly it's not that easy…

             

            It depends how you define "empty".

            Is a text frame empty, if it shows no content, but

             

            myTextFrame.overflows
            

             

            is true? Technically it's empty, but you can wisely decide not to put in the same category with text frames that are "empty" and do not overflow. In that case your contents test will give a false positive.


            Even more important is the case of a table that is threaded to a few text frames.
            For the first text frame that holds the start of the table your test is fine, but for all other text frames that hold parts of the table you'll get false positives.

             

            To test against this case is a really tough task…

            I have no easy answer in this case, just a  method that match geometric properties of cells with the text frame singled out on an otherwise empty layer.

             

            Uwe

            • 3. Re: Find TextFrame Empty
              Laubender Adobe Community Professional & MVP

              Ok. After thinking a bit about the case with tables in threaded text frames there is a simple method to see, if the text frame is realy empty:
              Just duplicate the text frame and run a test on the duplicate as well. If it is holding a table now, its contents.length property is not "0" any more.

               

              Uwe

              • 4. Re: Find TextFrame Empty
                winterm Level 4

                @Uwe - oh yes, you're right, it's not that easy...

                 

                I personally use 2 or 3 different scripts in different projects just to manage those "empty text frames"... Step by step, trying not to loose control. Yeah, they have many faces, especially in careless designers projects.

                 

                you see, OP question itself is not clear enough...

                instead of asking back more questions, I made an attempt just to give a very basic, simple answer.

                Code I posted just finds and selects first "empty frame", and it's up to user decide is it really "empty" and what to do with it...  Script won't do the whole job for you in seconds, but it won't do any harm either.

                It's just a decent starting point, I think.

                 

                To go further, one must know, what exactly he expects to find and what to do with it.

                And then, maybe, he'll need a little help from REAL scripter (it's not me, but I know YOU are )