Skip to main content
Known Participant
September 19, 2008
Question

Horizontal TextFrame fitting

  • September 19, 2008
  • 5 replies
  • 835 views
I have a TextFrame with content that is different depending on the situation. So after I set the TextFrame content, I want to fit the frame to the content but only horizontally.
It's easy to do it in the InDesign UI (double click on a left or right side guide of the frame).
But how can I implement this functionality in IDS?

Any suggestions?

Thanks in advance.
This topic has been closed for replies.

5 replies

Inspiring
October 24, 2008
Participant
October 24, 2008
I have a textframe with bottomaligned text in it.
Now I want to fit the frame to the content.
In script this is
TextFrame.fit(FitOptions.frameToContent).
But this is resulting in the bottom edge of the frame going up until the frame fits around the text.
I want however to have the bottomline of the frame to stay where it is and the topline of the frame going down.
The same as double clicking the handle of the topline in the desktop version.
How can i do this in script?
Inspiring
September 25, 2008
You might want to take a look here:

http://www.adobeforums.com/webx/.3bbf275d.59b6878b/1

That topic was triggered by my posting here.

Dave
bART2007Author
Known Participant
September 25, 2008
Thanks Dave! This is exactly what I needed.
Inspiring
September 19, 2008
You need to write a script. One way of doing it would be along these lines;

var gbs = myFrame.geometricBounds;
var maxR = getMax(myFrame.insertionPoints.everyItem().horizontalOffset);
gbs[3] = maxR;
myFrame.geometricBounds = gbs;

function getMax(anArray) {
return anArray.sort(revNumerical)[0];
function revNumerical(a,b) { return b-a }
}

This assumes that the frame has no inset or strokeweight. If it doesn't, this works like a charm. But if it did have them, you'd have to do extra work to take those into account. I guess it also assumes that the frame is rectangular.

Dave