1 Reply Latest reply on Oct 7, 2009 8:50 AM by [Jongware]

    CS4 Automatically resizing text frame height to baseline of last text line

    ChungNYC

      Hi,

       

      Does anyone know of a script that will automatically resize all text frame heights in a document so that the bottom of each text frame falls on the baseline of the last line of text within in the text frame? The height of the frame should be determined by the text shown and not be affected by overset or threaded stories.

      Thanks!!

      Chung

        • 1. Re: CS4 Automatically resizing text frame height to baseline of last text line
          [Jongware] Most Valuable Participant

          As text frames have a property 'lines', and lines have a property 'baseline', and frames have a property 'geometricBounds', this quickly written javascript ought to do the trick for a currently selected text frame:

           

          app.selection[0].geometricBounds = [app.selection[0].geometricBounds[0],app.selection[0].geometricBounds[1],app.selection[0].lines[app.selection[0].lines.length-1].baseline,app.selection[0].geometricBounds[3]];

           

          (Whaddoyouknow: it can be done in a single line )

           

          So let's loop over all text frames in your current doc:

           

          allf = app.activeDocument.textFrames;
          for (f=0; f<allf.length; f++)
           allf[f].geometricBounds = [allf[f].geometricBounds[0],allf[f].geometricBounds[1],allf[f].lines[allf[f].lines.length-1].baseline,allf[f].geometricBounds[3]];