prawnpdf / prawn-table

Provides support for tables in Prawn
Other
205 stars 98 forks source link

Page break logic only checks the first column #155

Open vanboom opened 11 months ago

vanboom commented 11 months ago

Consider a table where the first column has an index number, with multi-line text in the subsequent columns.

E.g.

index title description
1. A short title Some very long multi-line text....

The start_new_page? method only checks the first column in a row to see if it fits on the page... https://github.com/prawnpdf/prawn-table/blob/38b5bdb5dd95237646675c968091706f57a7a641/lib/prawn/table.rb#L424

If one of the other cells wraps to multi-line at the end of a page, a new page will not result.

Suggestion: consider removing the cell.column == 0 check so that the row will start a new page if any of the row content will not fit on the current page.

    # OLD WAY - check only column 0
      # (cell.column == 0 && cell.row > 0 &&
      #  !row(cell.row).fits_on_current_page?(offset, ref_bounds))

      # NEW WAY - check all columns
      (cell.row > 0 &&
      !row(cell.row).fits_on_current_page?(offset, ref_bounds))