Skip to main content
dublove
Legend
July 9, 2025
Answered

Use script, how to find out text frame with script and release 2-3 lines of overflow text?

  • July 9, 2025
  • 1 reply
  • 480 views

For example:
You now have 6 objects selected that may contain text frame and images。

How tu  use a script to find out the text frame, ,  theb release 2-3 lines of overflow text if there is any.

whole file here

 

 

 

Correct answer rob day

@Manan Joshi 

mytextFrame = app.selection[0];
if (mytextFrame.constructor.name == "TextFrame")
  if (mytextFrame.overflows)
{

......

}

If if (mytextFrame. overflow) is true, how to expand mytextFrame down 3-5 lines (or increase the height of the text box by 5mm)

 


You can use the textFrame’s fit() method on the selected text frames that have overflows:

 

var s = app.documents[0].selection;

for (var i = 0; i < s.length; i++){
    //get the text frames that overflow
    if (s[i].constructor.name == "TextFrame" && s[i].overflows) {
        s[i].fit(FitOptions.FRAME_TO_CONTENT)
    } 
};   

 

 

 

 

 

 

 

 

1 reply

Mike Witherell
Community Expert
Community Expert
July 9, 2025

Why not build and apply a caption text frame Object Style that has the ability to grow downward to accommodate the volume of text? See Object menu > Text Frame Options > Auto-Size... Auto-Sizing > Height Only > click from top arrow, OK

Mike Witherell
dublove
dubloveAuthor
Legend
July 10, 2025

It's a pity.
My good post... ... ...

Community Expert
July 11, 2025

Use what @Mike Witherell suggested. Don't use scripting everywhere even if not needed. First look for existing features. Having said that you might want to think of a solution to a problem wherein the caption might overlap over the Image below it while resolving the overset.

-Manan

-Manan