Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How  to use a script to make the bottom and right sides of a textFrame fit the content?

Guide ,
Sep 20, 2025 Sep 20, 2025

Using a frame to fit the content seems to only shrink the bottom.

I just ran into this problem again today.

Double-clicking the box on the right will definitely work.

666.png

TOPICS
How to , Scripting
122
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Sep 21, 2025 Sep 21, 2025

Hey,

Well, I don't see why double clicking on the handles wouldn't work. Any of them do work for me.

If they don't for some reasons, you could indeed bypass the bug with a script.
What you basically do is activating/ deactivating the autofit option on the selected textframe, using the settings your prefer. In the meantime, there is already something canon in ID for modifying the options of the selected texframe (right-click, Text frame option / CMd+B). Not sure a script is relevant here. 

Anyways, t

...
Translate
Engaged ,
Sep 21, 2025 Sep 21, 2025

Hey,

Well, I don't see why double clicking on the handles wouldn't work. Any of them do work for me.

If they don't for some reasons, you could indeed bypass the bug with a script.
What you basically do is activating/ deactivating the autofit option on the selected textframe, using the settings your prefer. In the meantime, there is already something canon in ID for modifying the options of the selected texframe (right-click, Text frame option / CMd+B). Not sure a script is relevant here. 

Anyways, the code could be then something like that :

var selectedItem = app.selection[0];
selectedItem.textFramePreferences.autoSizingType = AutoSizingTypeEnum.WIDTH_ONLY;
selectedItem.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.LEFT_CENTER_POINT;
selectedItem.textFramePreferences.autoSizingType = AutoSizingTypeEnum.OFF;

 

If the purpose of the script is to adjust the width of every textframe of the active document, then, a script would obviously not be an option, but pretty much mandatory if you want to really save some time. Just making a loop on all the textframes of the document will do

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 21, 2025 Sep 21, 2025

Hi @Fred.L 

Thank you very much.

Double-clicking the handle works.
It seems the left side jumped a bit—can you keep it stationary?
Did it contract toward the center?

 

Changing it to TOP_LEFT_POINT still seems to center it.

This line seems ineffective:

selectedItem.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.BOTTOM_LEFT_POINT;


Removing it makes no difference.

669.png

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2025 Sep 21, 2025

Hi @dublove ,

assign both property/value pairs at the same time like that:

var selectedItem = app.selection[0];

selectedItem.textFramePreferences.properties =
{
	autoSizingType : AutoSizingTypeEnum.WIDTH_ONLY ,
	autoSizingReferencePoint : AutoSizingReferenceEnum.LEFT_CENTER_POINT
};

 

Or change the order of assigning the values like that:

var selectedItem = app.selection[0];

selectedItem.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.LEFT_CENTER_POINT;
selectedItem.textFramePreferences.autoSizingType = AutoSizingTypeEnum.WIDTH_ONLY;

 

Kind regards,
Uwe Laubender
( Adobe Community Expert )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 21, 2025 Sep 21, 2025

Hi @Laubender 

Thank you very much.

That's a good idea. I'll ditch HEIGHT_AND_WIDTH and just adjust the WIDTH_ONLY, then use fit(FitOptions.FRAME_TO_CONTENT).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 21, 2025 Sep 21, 2025

I think I know how to proceed now. Thank you very much.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2025 Sep 21, 2025
LATEST

@dublove said: "… How can I identify and avoid applying it to these cases?"

Well, one text frame contains a single line of text without a table, the other one contains multiple lines of text without a table and the 3rd sample contains a table only.

 

The if statements for the 3 cases could contain:

 

myTextFrame.texts[0].lines.length == 1 
&& 
myTextFrame.texts[0].tables.length == 0

 

myTextFrame.texts[0].lines.length > 1 
&& 
myTextFrame.texts[0].tables.length == 0

 

myTextFrame.texts[0].lines.length == 1 
&& 
myTextFrame.texts[0].tables.length == 1

 

Kind regards,
Uwe Laubender
( Adobe Community Expert )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines