Skip to content
This repository

Add initial x coordinate to add_header #372

Closed
wants to merge 2 commits into from

3 participants

Ivan Tse Gregory Brown Ivan Tse
Ivan Tse

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)

Gregory Brown
Owner

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.

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

Showing 2 unique commits by 2 authors.

Jul 13, 2012
Set initial x coordinate for header cells 32fdbe9
Ivan Tse Refactor the fix 4f25d6e
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 5 additions and 4 deletions. Show diff stats Hide diff stats

  1. 9  lib/prawn/table.rb
9  lib/prawn/table.rb
@@ -295,7 +295,7 @@ def draw
295 295
         # Track cells to be drawn on this page. They will all be drawn when this
296 296
         # page is finished.
297 297
         cells_this_page = []
298  
-
  298
+        
299 299
         @cells.each do |cell|
300 300
           if cell.height > (cell.y + offset) - ref_bounds.absolute_bottom &&
301 301
              cell.row > started_new_page_at_row
@@ -309,8 +309,9 @@ def draw
309 309
 
310 310
             # start a new page or column
311 311
             @pdf.bounds.move_past_bottom
  312
+            x_offset = @pdf.bounds.left_side - @pdf.bounds.absolute_left
312 313
             if cell.row > 0 && @header
313  
-              header_height = add_header(cells_this_page, @pdf.cursor, cell.row-1)
  314
+              header_height = add_header(cells_this_page, x_offset, @pdf.cursor, cell.row-1)
314 315
             else
315 316
               header_height = 0
316 317
             end
@@ -488,10 +489,10 @@ def make_cells(data)
488 489
     #
489 490
     # Return the height of the header.
490 491
     #
491  
-    def add_header(page_of_cells, y, row)
  492
+    def add_header(page_of_cells, x_offset, y, row)
492 493
       @header_row.each do |cell|
493 494
         cell.row = row
494  
-        page_of_cells << [cell, [cell.x, y]]
  495
+        page_of_cells << [cell, [cell.x + x_offset, y]]
495 496
       end
496 497
       @header_row.height
497 498
     end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.