lib/prawn/table.rb in prawn-1.0.0 vs lib/prawn/table.rb in prawn-1.1.0

- old
+ new

@@ -41,10 +41,20 @@ Table.new(data, self, options, &block) end end + module Errors + # This error is raised when table data is malformed + # + InvalidTableData = Class.new(StandardError) + + # This error is raised when an empty or nil table is rendered + # + EmptyTable = Class.new(StandardError) + end + # Next-generation table drawing for Prawn. # # = Data # # Data, for a Prawn table, is a two-dimensional array of objects that can be @@ -318,11 +328,13 @@ # Ink all cells on the current page if defined?(@before_rendering_page) && @before_rendering_page c = Cells.new(cells_this_page.map { |ci, _| ci }) @before_rendering_page.call(c) end - Cell.draw_cells(cells_this_page) + if @header_row.nil? || cells_this_page.size > @header_row.size + Cell.draw_cells(cells_this_page) + end cells_this_page = [] # start a new page or column @pdf.bounds.move_past_bottom x_offset = @pdf.bounds.left_side - @pdf.bounds.absolute_left @@ -525,10 +537,10 @@ def add_header(page_of_cells, x_offset, y, row, row_of_header=nil) rows_to_operate_on = @header_row rows_to_operate_on = @header_row.rows(row_of_header) if row_of_header rows_to_operate_on.each do |cell| cell.row = row - cell.dummy_cells.each {|c| c.row = row } + cell.dummy_cells.each {|c| c.row = row + c.row } page_of_cells << [cell, [cell.x + x_offset, y]] end rows_to_operate_on.height end