: How to "fit frame to content" with overset text, to a single line in InDesign I would like for when I choose "fit frame to content" on a text box with overset text, the frame width is adjusted
I would like for when I choose "fit frame to content" on a text box with overset text, the frame width is adjusted to fit the remaining text, rather than the height. The image should visually explain.
More posts by @Cooney243
2 Comments
Sorted by latest first Latest Oldest Best
Here is a little script that does, what you want to do:
#target InDesign
if(!(app.selection.length == 1
&& app.selection[0] instanceof TextFrame
&& app.selection[0].overflows)){
alert("ErrorrSelect exactly one text frame with overset text and try again.");
exit();
};
var tf = app.selection[0];
var increment = 1;
var spreadWidth = calculateSpreadWidth();
while(tf.overflows){
var bounds = tf.geometricBounds;
tf.geometricBounds = [bounds[0], bounds[1], bounds[2], bounds[3] + increment];
if((bounds[3] - bounds[1]) >= spreadWidth){
alert("ResultrThe text frame has reached the width of the spread and will not be increased in width any further.");
break;
}
}
function calculateSpreadWidth(){
var spread = app.activeWindow.activeSpread;
var firstPageBounds = spread.pages.item(0).bounds;
var lastPageBounds = spread.pages.item(-1).bounds;
return (lastPageBounds[3] - firstPageBounds[1]);
}
This will keep the number of lines and just increase the text frame width until it fits without overset text or until it reaches the width of the spread, whichever happens first.
So far this is not a very sophisticated script, so it might not work when your formatting is more advanced (more than one column in your text frame, larger point sizes in your overset text, etc.).
You could save this script as a .jsx file, move it to your scripts folder and even assign a custom keyboard shortcut to it, so you could quickly use it with one keystroke when you have a text frame selected.
Looks like it's not possible. The only way I could see it is you overlap your textbox above your frame to get the same effect.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.