Skip to main content
dublove
Legend
July 4, 2025
Answered

How to find small amounts of overflow text and expand them with a script?

  • July 4, 2025
  • 1 reply
  • 178 views

I want to find these overflow text boxes, 

and then keep the width of the text box constant, increase the height and expand the text.

 

A small amount here means cases where the overflow is only a few lines (ex: 6 lines).

Expand only on current page.
Ignore those cases where you need to increase the page to expand them.

 

Thank you very much.

Found this written by jb_alvarado:

Can it be modified to only expand on the current page?

 

var storyTitle = "Hello I'm a title!"
var myDocument = app.documents.item(0);
var myDoc = app.activeDocument;
var myFrames = app.selection[0].parent;
var myIndexStart = app.selection[0].parentTextFrames[0].index;
while (myFrames.overflows === true) {
    var myNewPage = myDoc.pages.add();
    myNewPage.appliedMaster = myDoc.masterSpreads.item("A-Text");
    // add Page header
    myTitleFrame = myNewPage.textFrames.add();
    myTitleFrame.contents = storyTitle;
    myTitleFrame.geometricBounds = ["0mm", "0mm", "4.98mm", "148mm"];
   

 

Perhaps, there is no need for these latter.

 

 myTitleFrame.move([0, 8.62]);
    myTitleFrame.textFramePreferences.textColumnCount = 1;
    myTitleFrame.texts[0].appliedParagraphStyle = myDocument.paragraphStyleGroups.item("Meist genutzte").paragraphStyles.item("Seiten Kopf");
    var myMargin = myNewPage.marginPreferences;
    var myBounds = [myMargin.top, myMargin.left, myDoc.documentPreferences.pageHeight - myMargin.bottom, myDoc.documentPreferences.pageWidth - myMargin.right];
    var myOldRuler = myDoc.viewPreferences.rulerOrigin;
    myDoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
    with (myDoc.pages[-1].textFrames.add()) {
        geometricBounds = myBounds;
        if (myDoc.pages[-2].textFrames.length >= 3) {
            previousTextFrame = myDoc.pages[-2].textFrames[myIndexStart];
        } else {
            previousTextFrame = myDoc.pages[-2].textFrames[0];
        }
        textFramePreferences.textColumnCount = 2;
        textFramePreferences.textColumnGutter = 5;
    }
    myDoc.viewPreferences.rulerOrigin = myOldRuler;
}

 

Correct answer Willi Adelberger

To find overflow text use the Preflight Panel.

1 reply

Willi Adelberger
Community Expert
Willi AdelbergerCommunity ExpertCorrect answer
Community Expert
July 4, 2025

To find overflow text use the Preflight Panel.