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

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

Engaged ,
Mar 02, 2012 Mar 02, 2012

Copy link to clipboard

Copied

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

Views

11.6K

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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...

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

try this place

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

Jongware is the Master...

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

winterm wrote:

Jongware is the Master...

Oh you ain't seen nothing yet.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

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