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

Fit length of frame to text

Advocate ,
Feb 25, 2010 Feb 25, 2010

Does anyone know of a script for InDesign CS4 that will lengthen all the frames (vertically) throughout a document to fit the text when there is overset text and shorten the frame when the text doesn't fill out the full height of the frame?

TOPICS
Scripting
1.2K
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 , Feb 25, 2010 Feb 25, 2010

try below one

var myDoc =  app.activeDocument;

var mytextframe = myDoc.textFrames;

for (a=0; a<mytextframe.length; a++)

{

mytextframe.fit(FitOptions.FRAME_TO_CONTENT)

}

it will work if your text frame fit within your page else it leave as overset text frame.

Shonky

Translate
Engaged ,
Feb 25, 2010 Feb 25, 2010

try below one

var myDoc =  app.activeDocument;

var mytextframe = myDoc.textFrames;

for (a=0; a<mytextframe.length; a++)

{

mytextframe.fit(FitOptions.FRAME_TO_CONTENT)

}

it will work if your text frame fit within your page else it leave as overset text frame.

Shonky

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
Advocate ,
Feb 25, 2010 Feb 25, 2010

Cool! Works like a charm. Thank you, Shonky!


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
Explorer ,
Jun 20, 2019 Jun 20, 2019

Can you let it only target

Currently selected text box

Instead of all the text of the current document

This will help me thank all that can solve this problem.

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
Explorer ,
Jun 20, 2019 Jun 20, 2019

I hope someone can modify it.

Let it only target the currently selected object

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 ,
Jun 20, 2019 Jun 20, 2019

Try the following

if(app.selection.length > 0)

     app.selection[0].fit(FitOptions.FRAME_TO_CONTENT)

else

     alert("Please select an object before running the script")

-Manan

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
Explorer ,
Jun 21, 2019 Jun 21, 2019

Thank you very much, he is very effective.

But if multiple objects are selected, can they be adjusted together?

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 ,
Jun 21, 2019 Jun 21, 2019

Here you go

if(app.selection.length == 0)

     alert("Please select an object before running the script")

else

{

    for(var i = 0; i < app.selection.length; i++)

          if(app.selection.constructor.name == "TextFrame")

              app.selection.fit(FitOptions.FRAME_TO_CONTENT)

}

-Manan

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
Explorer ,
Jun 21, 2019 Jun 21, 2019
LATEST

thank you very much 

It is perfect now

May the Lord Jesus be with you.

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