prawn-layout icon indicating copy to clipboard operation
prawn-layout copied to clipboard

Overflow in a table cell causes page break

Open clescuyer opened this issue 16 years ago • 2 comments

I am struggling with an unwanted page break in a table. The contents of the cells varies in length. It seems some specific combinations of text length trigger the page break. Some much longer texts are displayed without a page break.

Here is the shortest snippet I found that has the page break. (I'm not using the font_size change in my app, it just happens to trigger the problem here.)

require 'rubygems'
require 'prawn/core'
require 'prawn/layout'
Prawn::Document.generate("problem.pdf") do
  @table = [[
    Prawn::Table::Cell.new(:text => "Some text with overflow.\nAnother line"),
    Prawn::Table::Cell.new(:text => 'foo'),
  ]]

  (8..9).each do |i|
    table @table, {:column_widths => { 0 => 100, 1 => 100}, :font_size => i}
  end
end

This happened in 0.5; I've built the gem from github and it's the same.

clescuyer avatar Sep 28 '09 15:09 clescuyer

can you write a unit test to see if width_of() is reporting back incorrectly here?

practicingruby avatar Sep 29 '09 12:09 practicingruby

Yes I will

clescuyer avatar Sep 29 '09 14:09 clescuyer