Razor-sharp InDesign recipes

Tips & Tricks for Adobe InDesign: Adjust text frame height to last text line

All videos of the tutorial Razor-sharp InDesign recipes

This trick is really very small and simple, but still effective.

I have several text boxes here that are linked together. The problem is sometimes that I have drawn a text box too long.

How can I get it to go right up to the last line of text?

Some people may know that I can do this by double-clicking on the little handle at the bottom. Then I already have it. But sometimes it's not quite so easy to hit it.

Better: there is the option of programming a script to do this function for you.

Tips & Tricks for Adobe InDesign: Adjust text frame height to last text line


And I'll show you how to do it now.


Step 1

I go to the scripts directory. You can simply search for "Scripts Panel".

Right-click to create a new text document...

Tips & Tricks for Adobe InDesign: Adjust text frame height to last text line

Step 2

... and rename it however you like; I call it "textrahmen".

The file extension must be ".jsx" - just like the other files.

Tips & Tricks for Adobe InDesign: Adjust text frame height to last text line

Step 3

You can edit this with any text editor, depending on what you have installed.

All you have to do is insert this code. You can also find it in the working materials of this tutorial.

myFrame = app.selection[0]; myBounds =
myFrame.geometricBounds; myBounds[2] =
myFrame.lines[-1].baseline; myFrame.geometricBounds = myBounds


Then I save this and close.

Tips & Tricks for Adobe InDesign: Adjust text frame height to last text line

Step 4

Next, I go to InDesign and then to the scripts panel.

There I now have the script "textrahmen". Just double-click on it and my text frame is exactly the right size.

Tips & Tricks for Adobe InDesign: Adjust text frame height to last text line



But it's a bit inconvenient if I have to double-click on it every time. I might as well look for the handle again.

But there is also the option of assigning keyboard shortcuts...

Step 5

In the menu under Edit you will find the keyboard shortcuts.

In the product area there is the option to select the scripts, and then all scripts that have been installed or user-defined scripts will appear.

I click on User: textrahmen.jsx and further down I can assign a keyboard shortcut.

Preferably one that is not yet assigned. I now simply say "F3" and the information that the command is "not yet assigned" appears immediately below.

So I click on Assign and confirm the whole thing with OK.

Tips & Tricks for Adobe InDesign: Adjust text frame height to last text line

Step 6

Now I can hide all windows, and if I test this, pull up the text box and then press the F3 key, it adapts to the text. Just as I wanted it to.

Tips & Tricks for Adobe InDesign: Adjust text frame height to last text line



And that's quicker than targeting the handle. What's more, it's totally simple: just three lines of code in this script and then created as a keyboard shortcut - and you can place text boxes in the exact size that fits the text.

And I think that's a nice thing, nothing earth-shattering, but it helps to speed up the workflow a bit.

With that in mind, I hope the tip goes down well!

See you at the next tutorial.