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

Script to select all overflow text frames and fit them to content?

Engaged ,
Mar 02, 2012 Mar 02, 2012

I have a document with several text frames that have overset text, due to replacing a font.  I was looking for a script that would:

1. find all the text frames that have overset text

2. apply "fit frame to content" command for each of these

Can anyone please help me here?  I'm trying to learn scripting but some of these things still confuse me.  Thanks.

TOPICS
Scripting
12.3K
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
Engaged ,
Mar 02, 2012 Mar 02, 2012

I think I've got it in Applescript, but out of curiosity, how would I do this in Javascript?

tell application "Adobe InDesign CS5.5"

          set myAllPageItems to all page items of page 1 of document 1

          repeat with theItem in myAllPageItems

                    set myType to class of theItem

                    if myType is text frame then

                              if overflows of theItem then

                                   fit theItem given frame to content

                              end if

                    end if

          end repeat

end tell

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
Mentor ,
Mar 02, 2012 Mar 02, 2012

hi,

give a try to this js code:

var _d = app.documents[0];

var _allStories = _d.stories;

for(var n=_allStories.length-1;n>=0;n--){

var _storyAllTextFrames = _allStories.textContainers;

for(var m=_storyAllTextFrames.length-1;m>=0;m--){

_storyAllTextFrames.select();

            //Fit Frame to Content:

            try{

            app.scriptMenuActions.itemByID(11291).invoke();

                }catch(e){};

           try{

           app.scriptMenuActions.itemByID(278).invoke();

                }catch(e){};

            };

        };

Disclaimer:

I'm NOT a scripter. Sorry, don't remember exact origin of this code, but it works...

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 ,
Mar 02, 2012 Mar 02, 2012

Another approach:

var FO = FitOptions.FRAME_TO_CONTENT,

    tfs = ([]).concat.apply([], app.activeDocument.stories.everyItem().textContainers),

    t, i = tfs.length;

while( i-- ) (t=tfs).overflows && ( t.locked || t.fit(FO) );

@+

Marc

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
Engaged ,
Mar 02, 2012 Mar 02, 2012

Thanks.

Where is there a listing of properties such as .overflows and frame to

content? Like there is for Actionscript?

I tried the Extendscript tool but didn't see a listing. I wound up using

AppleScript due to the AS dictionary.

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
Mentor ,
Mar 03, 2012 Mar 03, 2012

try this place

http://jongware.mit.edu/idcsjs5.5/

Jongware is the Master...

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 ,
Mar 03, 2012 Mar 03, 2012

winterm wrote:

Jongware is the Master...

Oh you ain't seen nothing yet.

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
Mentor ,
Mar 03, 2012 Mar 03, 2012

However, Bachman Turner Overdrive is one of my favorites...

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
New Here ,
Apr 04, 2013 Apr 04, 2013
LATEST

How can I apply this script to a specific text frame I labeled in Layers. Lets say I called this item "LeftText". Instead of fixing All text frames?

app.activeDocument.layers.itemByName("LeftText")

Thanks!

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