Auto Size text boxes
Learn / Forums / General InDesign Topics / Auto Size text boxes
Tagged: auto size
- This topic has 10 replies, 3 voices, and was last updated 6 years, 3 months ago by Vinny –.
-
AuthorPosts
-
-
January 9, 2018 at 9:56 am #100850Brenda EggertMember
I’m trying to set up a shortcut to change a text box to apply an auto size option in Text Frame Options/Auto Size. But I can’t seem to find one in the list that will take me there and change it to the height option I want. I see “Text Frame Options” in the list and I have a shortcut set up for that, but I want one that will take me farther into the options and change it to the height option I’m seeking. I also know I can set up an object style, but I’d have to do it for every existing job I open. Just trying to make it a single keystroke to change my height option.
-
January 11, 2018 at 2:37 pm #100894Claudio MarconatoMember
Hi Brenda, I don’t think that you can set a keyboard shortcut for that, I suggest to evaluate a search and replace with objects to apply what you need to. You can execute the search and replace to all the open documents.
Hope this helps
-
January 12, 2018 at 7:30 am #100916Vinny –Member
Hi Brenda.
I suppose this could be scripted. Then just apply a keyboard shortcut to the script.
Here’s an example I just wrote (based on Adobe’s CreateCharacterStyle.jsx):
Although I am very unsure how this WP forum handles codes and a bit worried it would remove some characters…main();
function main(){
//Make certain that user interaction (display of dialogs, etc.) is turned on.
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
if (app.documents.length != 0){
if (app.selection.length == 1){
switch (app.selection[0].constructor.name){
case “TextFrame”:
myDefineObjectStyle();
break;
default:
alert(“The selected object is not a text frame. Select some text and try again.”);
break;
}
}
else{
alert(“Please select a single text frame and try again.”);
}
}
else{
alert(“No documents are open. Please open a document, select some text, and try again.”);
}
}function myDefineObjectStyle(myCharacterStyleName){
var myDocument = app.activeDocument;
var myObjectStyleName = “Auto-resize text frame height”;//Create the object style if it does not already exist.
myObjectStyle = myDocument.objectStyles.item(myObjectStyleName);
try{
myObjectStyle.name;
}
catch (myError){
myObjectStyle = myDocument.objectStyles.add({name:myObjectStyleName});
}//Object Syle settings
myObjectStyle.basedOn = myDocument.objectStyles[0];
myObjectStyle.enableTextFrameAutoSizingOptions = true;
myObjectStyle.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY; //Change if necessary
myObjectStyle.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.TOP_CENTER_POINT; //Change if necessarymyObjectStyle.enableFill = false;
myObjectStyle.enableStroke = false;
myObjectStyle.enableStrokeAndCornerOptions = false;
myObjectStyle.enableParagraphStyle = false;
myObjectStyle.enableTextFrameGeneralOptions = false;
myObjectStyle.enableTextFrameBaselineOptions = false;
myObjectStyle.enableStoryOptions = false;
myObjectStyle.enableTextWrapAndOthers = false;
myObjectStyle.enableAnchoredObjectOptions = false;
myObjectStyle.enableFrameFittingOptions = false;}
// Apply ObjectStyle to the selection
var myObject = app.selection[0];
myObject.appliedObjectStyle = myObjectStyle; -
January 12, 2018 at 7:34 am #100917Vinny –Member
Hmmm not too bad… Apparently only quote marks have been converted.
In your code editor, just change them back (both opening and ending) to straight quotes and it should be OK.
^^ -
January 12, 2018 at 7:43 am #100918Vinny –Member
Oh and the last 3 lines should come before the preceding brace }
Pity we can’t edit posts… -
January 12, 2018 at 8:16 am #100919Brenda EggertMember
Do you have this as a link I can download? If I copy the script text, what would I put it into?
-
January 12, 2018 at 8:22 am #100920Vinny –Member
https://wetransfer.com/downloads/684c9bd386f5aefb6c94bb401f1cc4c020180112152103/ba62d0d6fc005eedce28d412defb387e20180112152103/790b0a
Place the file into your Scripts Panel -
January 12, 2018 at 10:35 am #100926Brenda EggertMember
Vinny, that worked like a dream! Thanks so much! Would it be too much to ask to have a second one that would take it backwards? i.e., a script that would turn the AutoSize off.
-
January 12, 2018 at 1:46 pm #100929Vinny –Member
Sorry Brenda, it’s weekend time…
Besides, what’s the point? Are you just trying to fit frame to content with a shortcut? If that so, you should be able to achieve it without scripting.
Could you be more specific about what exactly you want to do?
Also please note the provided script not only turn on autosizing, but also applied an object style. -
January 12, 2018 at 2:01 pm #100930Brenda EggertMember
I realized it created an object style after I manually changed a text box back to not having AutoSize. Because when I applied the script to a second text box on the same page, it made the first box go back to AutoSize and it lost my manual un-autosize. The reason I wanted a script to change it back to normal was because I like to use the AutoSize most of the time, but sometimes if I want to vertically center type in a box that is a certain depth, I have to go in and uncheck AutoSize. I don’t like to use “fit frame to content” for text because if I have to change the copy, it won’t automatically increase depth. But I appreciate your help with the script you created. I will continue to use it. Thanks so much!
-
January 15, 2018 at 1:38 am #100951Vinny –Member
Hi Brenda.
So if I understand well, you want to some of switch.
A script that would turn ON autosizing if it’s OFF and that would turn it OFF it was ON. Am I correct?
If that so, you can try the script below: (don’t forget to change quote marks to straight ones)
main();function main() {
//Make certain that user interaction (display of dialogs, etc.) is turned on.
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
if (app.documents.length != 0) {
if (app.selection.length == 1) {
switch (app.selection[0].constructor.name) {
case “TextFrame”:
AutosizeOnOff();
break;
default:
alert(“The selected object is not a text frame. Select some text and try again.”);
break;
}
} else {
alert(“Please select a single text frame and try again.”);
}
} else {
alert(“No documents are open. Please open a document, select some text, and try again.”);
}
}function AutosizeOnOff() {
var myDocument = app.activeDocument;
var myObject = app.selection[0];if (myObject.textFramePreferences.autoSizingType == AutoSizingTypeEnum.OFF) {
myObject.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.TOP_CENTER_POINT; //Change if necessary. See https://jongware.mit.edu/idcs6js/pe_AutoSizingReferenceEnum.html
myObject.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY; //Change if necessary. See https://jongware.mit.edu/idcs6js/pe_AutoSizingTypeEnum.html
alert(“Autosizing is now ON”); // delete this line if you don’t want the alert box anymore
} else {
myObject.textFramePreferences.autoSizingType = AutoSizingTypeEnum.OFF;
alert(“Autosizing is now OFF”); // delete this line if you don’t want the alert box anymore
}
}Download link below:
https://wetransfer.com/downloads/74d0c2189052ea61ce08f345896008d420180115083705/1192836602fa365851f4880b5dc73a3020180115083705/21a89cLet me know if it works for you
Vinny
-
-
AuthorPosts
- You must be logged in to reply to this topic.