8 Replies Latest reply on Aug 17, 2010 5:23 AM by sandy_88

    Text frames exceeds the margin

    sandy_88 Level 1

      Hi All,

       

      Is there any syntax for checking the text frame whether it is placed in the margin, if it is wrong (i.e., out of margin, especially bottom margin) it needs to show some alert for those pages or those page numbers need to be saved in some notepad.

       

       

      untitled.JPG

      I have attached one screenshot for your reference.

       

      For finding geometric bounds I have used the following syntax,

       

      var m = doc.pages[0].marginPreferences;
      var gbounds = [m.top, m.left,
      doc.documentPreferences.pageHeight - m.bottom,
      doc.documentPreferences.pageWidth - m.right];
      doc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;

      I need to know which page the text frames exceeds the margins.

       

      Is it possible, please help me.

       

      Sajeev

        • 1. Re: Text frames exceeds the margin
          Harbs. Level 6

          Is this what you are looking for?

           

          if(textFrame.overflows){

          alert("Too much text!");

          }

           

          Harbs

          • 2. Re: Text frames exceeds the margin
            sandy_88 Level 1

            No Harbs, I am not searching for the overflow text, I want the pages which the textframe size is exceeds the bottom margins.

             

            Sajeev

            • 3. Re: Text frames exceeds the margin
              Harbs. Level 6

              Ah.

               

              Check:

              frame.geometricBounds[2]

              against:

              page.bounds[2]- page.marginPreferences.bottom;

               

              Harbs

              • 4. Re: Text frames exceeds the margin
                sandy_88 Level 1

                Sorry Harbs for the late reply.

                 

                Can you please explain little bit briefly.

                 

                Thanks

                Sajeev

                • 5. Re: Text frames exceeds the margin
                  PankChat Level 1

                  Well, what Harbs meant, you need to compare geometic bounds (bottom bound

                  precisely) of your frame with page bounds.

                   

                  I believe you are aware of GB syntax which read as an array [top, left,

                  bottom, right] bounds.

                   

                  you can do something below

                   

                  var myFrameBottomBounds=frame.geometricBounds[2];

                  var myPageBottomBound=page.bounds[2]- page.marginPreferences.bottom;

                   

                  and now compare the above two to find ou whether you frame bound is bigger

                  than page bound. You may also require to check left

                  (frame.geometricBounds[1] ) or right (frame.geometricBounds[3] ) or even

                  top (frame.geometricBounds[0]) to get the desire conditional check.....

                  which depends on your requirements.

                   

                  You may also like to set your rulers to before comparing (I

                  generally do that) bounds.

                   

                  Something like below:

                   

                  myDoc.zeroPoint = Array(0,0)

                  with (myDoc.viewPreferences){

                  var myOldXUnits = horizontalMeasurementUnits;

                  var myOldYUnits = verticalMeasurementUnits;

                  horizontalMeasurementUnits = MeasurementUnits.millimeters;

                  verticalMeasurementUnits = MeasurementUnits.millimeters;        

                  ......

                   

                   

                  }

                   

                  Now you will get the values in "mm" (easy to see debug)

                   

                  HTH,

                   

                  Pankaj

                  • 6. Re: Text frames exceeds the margin
                    Harbs. Level 6

                    It's really simpler than that. For a simple check like this, there should not be a need to mess with measurement units or the zero point.

                     

                    This should suffice:

                     

                    if( frame.geometricBounds[2] > (page.bounds[2] - page.marginPreferences.bottom)){
                         //the frame is too low...
                    }
                    
                    
                    • 7. Re: Text frames exceeds the margin
                      PankChat Level 1

                      Cool.

                       

                      It means I can compare for the rest of bounds also.

                       

                      if( frame.geometricBounds[0] > (page.bounds[0] -

                      page.marginPreferences.top)){

                           //the frame lies above page top margin

                      }

                      That shortens my unnecessary written code in one of my script.

                       

                      Thanks Harbs.

                      • 8. Re: Text frames exceeds the margin
                        sandy_88 Level 1

                        Hi Pankaj and Harbs,

                         

                        Thanks for your help. It really helps me.

                         

                        I have completed the task with help of your codings .

                         

                        Sajeev