Skip to main content
Participating Frequently
June 18, 2025
Answered

Shortcut to find shortened text boxes

  • June 18, 2025
  • 1 reply
  • 700 views

Is there a GREP etc way to find quickly all pages in a doc in which the text boxes have been manually shortened

Correct answer Manan Joshi

Hi Manan, yes, that's exactly what is needed.

 


Not doable via Grep but script may help. Try the following code.

var doc = app.documents[0];
var tolerance = 0.5; // in points — tweak if needed

for (var i = 0; i < doc.pages.length; i++) {
    var page = doc.pages[i];

    var mp = page.marginPreferences;
    var top = page.bounds[0] + mp.top;
    var bottom = page.bounds[2] - mp.bottom;
    var left = page.bounds[1] + mp.left;
    var right = page.bounds[3] - mp.right;

    var marginWidth = right - left;
    var marginHeight = bottom - top;

    if (page.textFrames.length > 0) {
        var tf = page.textFrames[0];
        var gb = tf.geometricBounds;
        var tfHeight = gb[2] - gb[0];
        var tfWidth = gb[3] - gb[1];

        var widthDiff = Math.abs(tfWidth - marginWidth);
        var heightDiff = Math.abs(tfHeight - marginHeight);

        if (widthDiff > tolerance || heightDiff > tolerance) {
            alert("Page " + page.name + " has a mismatched text frame.");
        }
    }
}

Do note the following

  1. The script needs an open document in InDesign
  2. The tolerance for variation in size is .5 pt
  3. The script assumes that we have only a single textframe on each page
  4. The output is in the form of an alert on which pages have the problem.

-Manan

1 reply

Community Expert
June 18, 2025

What would be the definition of shortened? Is it done by applying some object style? If so then you could find it else I don't think so it is possible via search. However, a script can do the job, if you define your needs in a bit more detail

-Manan

Participating Frequently
June 18, 2025

Hi Manan, so good of you to reply, thank you. It's a long document where all pages by default have the same height of text boxes. However, some of them have been manually shortened, by grabbing the handles on the bottom line and dragging the box up. I need to find all of the pages that have these shortened text boxes. 

rob day
Community Expert
June 18, 2025

It's a long document where all pages by default have the same height of text boxes

 

Hi @defaultdeb30zd009k6 , Is there only one text frame per page, and is the text frame supposed to align to the page margins? Something like this: