Skip to main content
dublove
Legend
Jul 9, 2025 2:40 PM UTC
Answered

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

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

 

 

 

rob day
rob dayCorrect answer
Community Expert
Jul 11, 2025 6:47 PM UTC

@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)
    } 
};   

 

 

 

 

 

 

 

 

8 replies

Mike Witherell
Community Expert
Community Expert
Jul 9, 2025 3:47 PM UTC

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

Translate
Mike Witherell
dublove
dubloveAuthor
Legend
Jul 10, 2025 11:47 AM UTC

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

Translate
Community Expert
Jul 11, 2025 4:31 AM UTC

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

Translate
-Manan