prawnpdf / prawn-table

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

Layout error for tables with vertical span cells #106

Open rillbert opened 6 years ago

rillbert commented 6 years ago

Steps-to-reproduce

  1. Create a document with a table where the first row contains a cell with vertical span.
  2. Taylor the document in such a way that the cell with vertical span does not fit between the current rendering position on a page and the bottom margin.
  3. Render the document.

Expected Result

ok.pdf

Actual Result

error.pdf

Probable cause

In file Table.rb, the following code exists


def initial_row_on_initial_page
  # we're at the top of our bounds
  return 0 if fits_on_page?(@pdf.bounds.height)

  needed_height = row(0..number_of_header_rows).height

needed_height is calculated without consideration to vertical span.

Proposed fix:

Change the above to:


def initial_row_on_initial_page
  # we're at the top of our bounds
  return 0 if fits_on_page?(@pdf.bounds.height)

  needed_height = row(0..number_of_header_rows).height_with_span

to account for vertical span.

Both of the above pdf's were rendered via asciidoctor-pdf from the same asciidoc source, one with, one without the fix above. The reason I used asciidoctor-pdf is that I don't have any experience of working directly with prawn-pdf so this was the quickest way for me to render the example docs.

I managed to create a pull request with the above fix (I hope...)

Cheers /Anders