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.
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
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...
North America
Europe, Middle East and Africa
Asia Pacific