Resizing Text Boxes in Quark

Hi Folks,
I am hoping that someone may know the answer to this, or at least say something that points me in the right direction.

The problem I have is this: I want to programmatically resize a text box so that the text inside it is visible. The Quark document I’m working with has text boxes that don’t show all the text within them. What I need to do is increase the text box’s height so as all the text will be visible, but I don’t know how a script can deduce this information.

I’ve tried line count, but curiously that only shows the visible number of lines, not the complete number of lines. I’ve looked at the properties for the story, text box, and paragraph but there doesn’t seem to be any obvious property that I can query.

I have been able to write a script that shrinks a text box to the text that it contains; and I had thought this might work for the problem I’ve outlined above. I had thought the baseline of the last character would reveal that it is greater than the height of the text box.

Hope this is clear, please let me know if not, and I’ll try to clarify.

P.S: I’m working with Quark 6.5

It’s been a while since I have scripted anything like this in Quark and I don’t have it here to check what I’m about to post. However, I think that if you refer to the story instead of just the text box then you can address text which is outside of the text box. So, if you do not have a tex box that is linked you should be able to try this:

if box overflows of text box 1 is true then
Set StoryLeading to (leading of every line of story 1 of text box 1)
set NewBoxHeight to height of line 1 of story 1 of text box 1
if count of StoryLeading > 1 then
repeat with i from 2 to count of StoryLeading
Set NewBoxHeight to NewBoxHeight + item i of StoryLeading
end repeat
set height of bounds of text box 1 to NewBoxHeight
end if
end if

It will probably take some tweeking to make sure the measures are all in the same format. Basically what I am trying to do with this is get the height of the first line then add the leading of every other line in the stroy to come up wth the height. You might need to add a bit more at the bottom to get the last line in, it depends on how Quark is deals with the decenders.

If the above does not work an easier, but less elegant way to deal with it would be:

tell text box 1
repeat while (box overflows) is true
set height of bounds to height of bounds +1
end repeat

this should just add one to the height untill there is no overflow, which could take a while or error out when it opens the text box beyond the past board.

Hope that this helps.

Hi Jerome,
Thanks for this reply. I gave your scripts a few tweaks and it seems to be working. The line I had problems with was Set StoryLeading to (leading of every line of story 1 of text box 1) Applescript reported that it couldn’t find the leading of every line. That’s something I mention more for reference, the key thing was the ‘if box overflows’ since if the worse case scenario would be for me to display an alert informing the user that this text box needs to be sized correctly.

Many thanks for taking the time. It’s much appreciated.