Equally distribute text across two columns in column box

120 views
Skip to first unread message

Michael Kastner

unread,
Jan 23, 2012, 4:09:33 AM1/23/12
to Prawn
Hi,

is there a way to distribute a text equally across to columns in a
column box?

Maybe I am doing something wrong here, but if I do not explicitly set
the height value only the first column is being populated with text.
On the other hand, if I do set an explicit height the text flows
nicely to the second columns, but then the height of the columns not
automatically adjust to the length of the text.

column_box([0, cursor], columns: 2, width: 330, height: 200) do
text content.article.body[0..900], size: 11
end

I'm using Ruby 1.9.3 and Prawn 1.0.0.rc1

Any help is appreciated.

Michael Kastner

Sara T

unread,
Jan 23, 2012, 11:41:47 AM1/23/12
to Prawn

Brad Ediger

unread,
Jan 23, 2012, 2:25:52 PM1/23/12
to prawn...@googlegroups.com
On Mon, Jan 23, 2012 at 3:09 AM, Michael Kastner <kas...@galt.de> wrote:
> Maybe I am doing something wrong here, but if I do not explicitly set
> the height value only the first column is being populated with text.

I'm not sure what you mean here. If I do something like this, I get
text in both columns:

column_box [0, cursor], columns: 2, width: 330 do
text "lorum ipsum dolor sit amet " * 500
end

The columns default to the height of their containing bounding box,
and they flow left to right.

> On the other hand, if I do set an explicit height the text flows
> nicely to the second columns, but then the height of the columns not
> automatically adjust to the length of the text.

That's right -- if you want to balance the columns in height, you'll
have to try to figure out first what height that should be. Prawn's
column boxes (like newspaper or magazine columns) just flow
left-to-right, they don't try to balance each other.

Brad

Michael Kastner

unread,
Jan 24, 2012, 12:46:12 AM1/24/12
to Prawn
> That's right -- if you want to balance the columns in height, you'll
> have to try to figure out first what height that should be. Prawn's
> column boxes (like newspaper or magazine columns) just flow
> left-to-right, they don't try to balance each other.


I see, so I need to do some calculations about the amount of space the
text will occupy.

Thanks for the explanation

Michael

PS: Prawn is way cool!
Reply all
Reply to author
Forward
0 new messages