Skip to main content
Known Participant
November 24, 2023
Answered

Select text boxes with overset text

  • November 24, 2023
  • 2 replies
  • 918 views

Hello,

 

I was trying to think in a script where is possible to select all text boxes with overset text inside a page and/or in the whole document.

 

I see there is textFrame.overflows possibility in the script but this only returns true or false. I can't think how to return the boolean in concrete itens.

 

Any thoughts?
Thank you
Danilo 

This topic has been closed for replies.
Correct answer Peter Kahrel

As Robert pointed out, you can select frames only on a single page or spread, so you need two scripts: one to select overset frames on a page and another to apply autosizing to all overset text frames in a document:

 

// Set Autosizing on overset frames

frames = app.documents[0].textFrames.everyItem().getElements();
for (i = 0; i < frames.length; i++) {
  if (frames[i].overflows) {
    frames[i].textFramePreferences.properties = {
      autoSizingReferencePoint: AutoSizingReferenceEnum.TOP_CENTER_POINT,
      autoSizingType: AutoSizingTypeEnum.HEIGHT_ONLY,
    }
  }
}

 

// Select overset frames on a page

overset = [];
frames = app.windows[0].activePage.textFrames.everyItem().getElements();
for (i = 0; i < frames.length; i++) {
  if (frames[i].overflows) {
    overset.push (frames[i]);
  }
}

if (overset.length > 0) {
  app.select (overset)
}

2 replies

Peter KahrelCorrect answer
Braniac
November 24, 2023

As Robert pointed out, you can select frames only on a single page or spread, so you need two scripts: one to select overset frames on a page and another to apply autosizing to all overset text frames in a document:

 

// Set Autosizing on overset frames

frames = app.documents[0].textFrames.everyItem().getElements();
for (i = 0; i < frames.length; i++) {
  if (frames[i].overflows) {
    frames[i].textFramePreferences.properties = {
      autoSizingReferencePoint: AutoSizingReferenceEnum.TOP_CENTER_POINT,
      autoSizingType: AutoSizingTypeEnum.HEIGHT_ONLY,
    }
  }
}

 

// Select overset frames on a page

overset = [];
frames = app.windows[0].activePage.textFrames.everyItem().getElements();
for (i = 0; i < frames.length; i++) {
  if (frames[i].overflows) {
    overset.push (frames[i]);
  }
}

if (overset.length > 0) {
  app.select (overset)
}
Known Participant
November 24, 2023

Hi Peter,

Thank you so much! It works perfectly!

Best regards

Danilo

Robert at ID-Tasker
Braniac
November 24, 2023

Boolean have two values - True or False. 

 

You can select - manually or from script - ONLY items on the same page / spread - you can't on different spreads. 

 

Unless you would use my tool - but it's PC only... 

 

Known Participant
November 24, 2023

Hi Robert,

In the case for the whole document, I would like to transform and auto adjust the height only in the top of the text box.

In the case for the page, I would like to select them.

 

I have Mac, I think the tool won't work then.

 

Sorry for the confusion.

Best regards

Robert at ID-Tasker
Braniac
November 24, 2023

I'm not JS guy - but can you specify what do you mean by "auto adjust the height only in the top of the text box"? Top margin? Or the overall height of the TextFrame?