6 Replies Latest reply on Aug 9, 2011 6:38 AM by csm_phil

    clear the content of overset textframe

    zyberkid Level 1

      is there a way to clear the overset textframe,

       

      or atleast is there a way to find whether a textframe is overset?

       

      i have tried these methods, all failed

       

      textframe.overFlows => retuens false most of the time, if the textframe is overflown.

       

      tried the below method, no solid solution, anyhow.

      function isOverFlow(textFrame)
      {
      // if the textFrame is overset, delete the textframe.
           var isOverflow = false;
           // Text overflow detector block
           try
           {
                if(textFrame.parentStory.overFlows)
                {
                     isOverflow = true;
                }
                
                /*if(currentTextFrames[index].parentStory.tables.lastItem().cells != undefined)
                {
                     alert(currentTextFrames[index].parentStory.tables.lastItem().cells.lastItem());
                     var finalCell = currentTextFrames[index].parentStory.tables.lastItem().cells.lastItem();
                     if(finalCell != undefined)
                     {
                          if(finalCell.parent.parent.insertionPoints.lastItem().parentTextFrames.length==0)
                          {
                               isOverflow = true;
                          }
                     }
                }*/
           }
           catch(exception)
           {
                //set the overflow to false.
                isOverflow = false;
           }
      return isOverflow;
      }
      
      

       

      is there any possibility of clearing the contents in overset textframe.

        • 1. Re: clear the content of overset textframe
          csm_phil Level 4

          Hi Kid,

           

          Please try the below JS Code, i hope this clear all the overset text frame!

           

           

          var myDoc= app.activeDocument;
          var myPageItems = myDoc.allPageItems;
          for (var i =0; i<myPageItems.length; i++){
          if(myPageItems[i].constructor.name == "TextFrame"){
               var myOverFlowFrame = myPageItems[i];
               if(myOverFlowFrame.overflows==true){
                    app.select(myOverFlowFrame);
                    myPage = app.selection[0];
                    if(myPage.overflows==true){
                         while (myPage.overflows){
                              var myBounds = myPage.geometricBounds;
                                myBounds[2] += 50;
                                myBounds[2] -= 41;
                                myPage.geometricBounds = myBounds;
                                }
                           }
                      }
                 app.selection = null;
                 }
            }
          

           

          thx

          csm_phil

          • 2. Re: clear the content of overset textframe
            Mac_06 Level 2

            This is my understanding that Kid wanted to remove overset text frame from the document but your code increase the frame height while text sets to the tex frame.

             

            Just modify couple of line and it works fine:

            var myDoc= app.activeDocument;
            var myPageItems = myDoc.allPageItems;
            for (var i =0; i<myPageItems.length; i++){
            if(myPageItems[i].constructor.name == "TextFrame"){
                 var myOverFlowFrame = myPageItems[i];
                 if(myOverFlowFrame.overflows==true){
                      app.select(myOverFlowFrame);
                      myPage = app.selection[0];
                      if(myPage.overflows==true){
                           while (myPage.overflows){
                                myPage.remove()
                                  }
                             }
                        }
                   app.selection = null;
                   }
              }
            

             

            Mac

            • 3. Re: clear the content of overset textframe
              zyberkid Level 1

              Thanks for quick reply,

               

               

              but you know, the overflows property for my textframe always returns false. thats my problem

               

              myPage = app.selection[0];
                        if(myPage.overflows==true){
                             while (myPage.overflows){

               

              mypage.overflows is always false .

               

              i'm creating a textframe like using insertions points[-1] and adding the contents.

              • 4. Re: clear the content of overset textframe
                csm_phil Level 4

                Hi Kid,

                 

                What i am understand in your first post you want find the overflow text page, now i was post the overset frame increase the textframe.

                 

                Any way what you exact requirement.

                 

                thx

                csm_phil

                • 5. Re: clear the content of overset textframe
                  Mac_06 Level 2

                  The main culprit in your code is below line:

                   

                  if(textFrame.parentStory.overFlows)
                  
                  

                  Replace with

                  if(textFrame.parentStory.overflows)
                  


                  and wow... it starts working.

                   

                  Mac

                  • 6. Re: clear the content of overset textframe
                    csm_phil Level 4

                    Hi Kid

                     

                    Your code is working fine

                     

                    your code

                     

                    myPage = app.selection[0];
                              if(myPage.overflows==true){
                                   while (myPage.overflows){

                     

                     

                    this below code the selection of the text frame is remove it working good

                     

                    myPage = app.selection[0];
                      if(myPage.overflows==true){
                            myPage.remove()
                            }
                    

                     

                     

                    thx

                    csm_phil