Column box jumps a column with float and wraparound #461

Open
benhell opened this Issue Mar 15, 2013 · 1 comment

2 participants

@benhell

The following code is how I implement bulleted lists. However,
if the bulleted item is supposed to "wrap around"and appear at the top of the second column, it doesn't quite work. The bullet appears at the top of an otherwise empty second column, but then the text of the bullet appears in the third column.

 require 'prawn'

Prawn::Document.generate("jumpcol.pdf") do 
  column_box([0, cursor], columns: 3, width: bounds.width, height: font.height) do
     2.times do
       float{ indent(10){ text("*") } } 
       indent(20){ text("bullet text") }
     end 
  end 
end

If I remove the float and instead do "move_up(font.height)" after the bullet but before the text, I do not get this bug.

I speculate that the bullet character within the float triggers a new column (2). On exiting the float, the position is reset to the bottom of the first column. Then, the text following bullet character triggers another new column (3). Thus, three columns, the second being almost empty.

This is on 0.12. Haven't tested RC.

Wonderful project, btw. Truly sanity saving for me.

@practicingruby practicingruby removed the stale label Mar 17, 2014
@practicingruby
prawnpdf member

Your assumptions sound correct, and I think the core problem is that float is very naive in how it works: it keeps track of what page you start on and will rewind back to that page even if you crossed a page boundary, but isn't aware at all of what box you're in.

For this particular issue, I'd recommend using Unicode bullets in your text because it'll avoid having to hack around with float and indent, but the general problem is interesting enough that I'll re-open for further investigation / commentary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment