Skip navigation
Currently Being Moderated

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

Mar 2, 2012 7:38 AM

Tags: #script #javascript #command #applescript #overset #textframe

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.

 
Replies
  • Currently Being Moderated
    Mar 2, 2012 2:34 PM   in reply to Handycam

    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[n].textContainers;
    for(var m=_storyAllTextFrames.length-1;m>=0;m--){
    _storyAllTextFrames[m].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...

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 2, 2012 4:37 PM   in reply to Handycam

    Another approach:

     

    var FO = FitOptions.FRAME_TO_CONTENT,
        tfs = ([]).concat.apply([], app.activeDocument.stories.everyItem().textContainers),
        t, i = tfs.length;
    while( i-- ) (t=tfs[i]).overflows && ( t.locked || t.fit(FO) );
    

     

    @+

    Marc

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 3, 2012 2:48 PM   in reply to Handycam

    try this place

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

     

    Jongware is the Master...

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 3, 2012 4:15 PM   in reply to winterm

    winterm wrote:

     

    Jongware is the Master...

     

    Oh you ain't seen nothing yet.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 3, 2012 4:18 PM   in reply to [Jongware]

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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 4, 2013 10:31 AM   in reply to Marc Autret

    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!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points