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.
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
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...
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
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
winterm wrote:
Jongware is the Master...
Oh you ain't seen nothing yet.
Copy link to clipboard
Copied
However, Bachman Turner Overdrive is one of my favorites...
Copy link to clipboard
Copied
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!