Skip to main content
Participant
February 29, 2008
Question

Fit content to a two columns frame

  • February 29, 2008
  • 8 replies
  • 910 views
Hi Experts,

I need to fit content in to frame (it is a double column). But I can't see any feature in scripting. Manually also I can see fit option only for single column frame. Please advice me.

thanks,
Pasu
This topic has been closed for replies.

8 replies

Participant
March 1, 2008
Hi,

Thank you very much.

thanks,
Pasu
Jongware
Community Expert
Community Expert
February 29, 2008
"Great minds ..." ;-)

It works a treat, even on a full page of text with all sorts of images on top and lots of columns. I ran it a few times with larger and smaller images, just because it's fun to look at!
Kasyan Servetsky
Legend
February 29, 2008
Hi jongware,

You are reading my thoughts I was going to post the same code.

Kasyan
Jongware
Community Expert
Community Expert
February 29, 2008
Hah -- Scratch that previous post. Kasyan's idea works much better, provided you check first for not-overflows, then for overlflows. That way you can run it on just about any text frame you have, any number of columns, etc.

It boils down to

myTextframe = app.selection[0];
while (myTextframe.overflows == false)
{
var myBounds = myTextframe.geometricBounds;
myBounds[2] -= 1;
myTextframe.geometricBounds = myBounds;
}
while (myTextframe.overflows == true)
{
var myBounds = myTextframe.geometricBounds;
myBounds[2] += 1;
myTextframe.geometricBounds = myBounds;
}
Jongware
Community Expert
Community Expert
February 29, 2008
Well, that's a bit clearer. How about this -- building on Kasyan's script. The debugging alerts at the start show what properties to check. It fails
i spectacularly
if you try this on non-standard frames, f.e., if you put a text wrapping image over part of the first column :-)

myTextframe = app.selection[0];

numlines = myTextframe.lines.count();
alert ("Total: "+numlines);
numlines_1 = myTextframe.textColumns[0].lines.count();
alert ("1st column: "+numlines_1);

if (myTextframe.textColumns[0].lines.count() < myTextframe.textColumns[1].lines.count())
{
while (myTextframe.textColumns[0].lines.count() < myTextframe.textColumns[1].lines.count())
{
var myBounds = myTextframe.geometricBounds;
myBounds[2] += 1;
myTextframe.geometricBounds = myBounds;
}
} else
{
while (myTextframe.textColumns[0].lines.count() > myTextframe.textColumns[1].lines.count())
{
var myBounds = myTextframe.geometricBounds;
myBounds[2] -= 1;
myTextframe.geometricBounds = myBounds;
if (myTextframe.overflows)
{
myBounds[2] += 1;
myTextframe.geometricBounds = myBounds;
break;
}
}
}
Participant
February 29, 2008
Hi Kasyan,

Thanks for your reply.

I am not facing overflow problem. I have two columns textframe in which in one column contains full text and the other one contains partial text. Now I need to fit and make it equally distributed textframe. Can you please tell me your suggestion?

thanks,
Pasu
Kasyan Servetsky
Legend
February 29, 2008
Hi Pasu,
Here is a workaround for multicolumn text frames. I assume that active document has only one text frame and ruler units are set to millimeters.
//--------------------------------
var myDoc = app.activeDocument;
myTextframe = myDoc.textFrames[0];

while (myTextframe.overflows){
var myBounds = myTextframe.geometricBounds;
myBounds[2] += 1;
myTextframe.geometricBounds = myBounds;
}
//--------------------------------
Kasyan
Jongware
Community Expert
Community Expert
February 29, 2008
Fit content to frame -- you would want the text to size to fit a frame? As that's not an option for text in the UI, I presume you mean the other way around -- fit frame to content.

But it's quite interesting, I, for one, didn't know this until I tried. You
i cannot
fit frame to content if you have multiple text columns. The option disappears from the context menu, and is grayed out in the Object menu. Well, that's pretty conclusive -- you can't do this.

By the way: you are unclear about what "feature" you can't see in scripting. If you mean you can't find "Fit content to double column frame", well, there are lots of vaguely described actions that aren't in scripting. OTOH, just about every physical object has a method 'fit', which uses a FitOptions enumeration -- the very same list from the UI. The fact that it does not work on 2 column frames is something else.