Skip to content


Add initial x coordinate to add_header #372

wants to merge 2 commits into from

3 participants


If you use tables and column boxes, the table headers will not be drawn correctly. If the table flows to another column, the header for that column will be drawn as if it were a new page.

This fix will correctly draw the header with respect to the bounds.

(Sorry, I'm not sure how to write test(s) for this)

prawnpdf member

Hi. Please resolve merge conflicts and provide an example that reproduces the problem. I am closing the pull request for now, but feel free to reopen once you have updated your branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 13, 2012
  1. Set initial x coordinate for header cells

    Ivan Tse committed
  2. @ivantsepp

    Refactor the fix

    ivantsepp committed
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/prawn/table.rb
9 lib/prawn/table.rb
@@ -295,7 +295,7 @@ def draw
# Track cells to be drawn on this page. They will all be drawn when this
# page is finished.
cells_this_page = []
@cells.each do |cell|
if cell.height > (cell.y + offset) - ref_bounds.absolute_bottom &&
cell.row > started_new_page_at_row
@@ -309,8 +309,9 @@ def draw
# start a new page or column
+ x_offset = @pdf.bounds.left_side - @pdf.bounds.absolute_left
if cell.row > 0 && @header
- header_height = add_header(cells_this_page, @pdf.cursor, cell.row-1)
+ header_height = add_header(cells_this_page, x_offset, @pdf.cursor, cell.row-1)
header_height = 0
@@ -488,10 +489,10 @@ def make_cells(data)
# Return the height of the header.
- def add_header(page_of_cells, y, row)
+ def add_header(page_of_cells, x_offset, y, row)
@header_row.each do |cell|
cell.row = row
- page_of_cells << [cell, [cell.x, y]]
+ page_of_cells << [cell, [cell.x + x_offset, y]]
Something went wrong with that request. Please try again.