Skip to content

Offset problem with "keep_with_next (row)" option in a table. #153

Discussion options

You must be logged in to vote

Thanks @pointlessone (and congratulations for your awesome work on Prawn/table by the way).

The final workable code is:

module Prawn
  class Table
    
    alias :original_start_new_page? :start_new_page?
    
    def start_new_page?(cell, offset, ref_bounds)
      if cell.respond_to?(:keep_with_next?) # so not a dummy
        if cell.keep_with_next?
          # 
          # As much as rows we want
          # 
          (cell.keep_with_next + 1).times do |i|
            offset -= cells.rows(cell.row + i).height
          end
        end
      end
      original_start_new_page?(cell, offset, ref_bounds)
    end
end

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@pointlessone
Comment options

@PhilippePerret
Comment options

Answer selected by PhilippePerret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants