2 Replies Latest reply on Mar 4, 2010 12:07 AM by Marcos Suárez

    Script for search TextFrame whitout full text, and top align...

    Marcos Suárez Level 1

      This script "JUSTIFY_ALING" all text frames without footnotes:

       

      var TRUFI = app.activeDocument.textFrames.everyItem().getElements(),
           CHARLY;

      while( CHARLY=TRUFI.pop() )
           if ( CHARLY.footnotes.length == 0)
                CHARLY.textFramePreferences.verticalJustification = VerticalJustification.JUSTIFY_ALIGN;

       

      But I need that TextFrames whitout full text (for example: the text only go to the middle of the textframe) stay in TOP_ALIGN...

       

      Thanks for read me...

       

        • 1. Re: Script for search TextFrame whitout full text, and top align...
          [Jongware] Most Valuable Participant

          You can't tell right away if a textframe is filled all the way to the bottom. Even with linked text threads, there is usually a small space at the bottom, just not enough for an entire next line -- less than the leading of that next line. There may even be more space at the bottom, if the next frame starts with a heading, which is kept with a number of lines following it; or a large inline table or figure; or a hard page break. Or (come to think of it) a footnote -- I'm not sure what would happen then ...

           

          But you can get the vertical position of the last regular text line. With a text frame selected:

           

          alert (app.selection[0].lines.item(-1).baseline);

           

          will show you the absolute vertical position of that last line. If you need the distance from the top of its containing text frame, use

           

           

          alert (app.selection[0].lines.item(-1).baseline - app.selection[0].geometricBounds[0]);

           

          -- you might remember that the array 'geometricBounds' contains the positions of top, left, bottom, and right corners, in that order. So geometricBounds[0] is the top y position; subtract this from your baseline, and you know how low you go.

          In this case, you would want the distance from the last line to the bottom:

           

          alert (app.selection[0].geometricBounds[2] - app.selection[0].lines.item(-1).baseline) ;

          w
          will show you how much space there is left. A warning is in place: blank lines are also lines! (Theoretically, if this happens a lot, you could adjust for these. Left as an exercise.)
          All you have to do is ask yourself, what amount of white space at the bottom is allowed? Then check your frames for this, and only apply vertical justification if it's inside your parameters.
          (Apologies for those weirdly cramped final paragraphs. Sorry -- tried to restore it to normal readability, failed miserably. Jive Strikes Again!)
          2 people found this helpful
          • 2. Re: Script for search TextFrame whitout full text, and top align...
            Marcos Suárez Level 1

            A lot thanks...

             

            I will work in this way...