Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout error for tables with vertical span cells #106

Open
rillbert opened this issue Aug 17, 2018 · 0 comments
Open

Layout error for tables with vertical span cells #106

rillbert opened this issue Aug 17, 2018 · 0 comments

Comments

@rillbert
Copy link

rillbert commented Aug 17, 2018

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

  • The table should be drawn from the top of a new page.

ok.pdf

Actual Result

  • the table's first row is split. The cell with the vertical spacing is rendered on the page where it does not fit and the rest of the row is rendered on the next page without regard to the top margin. Note that the second table in the example docs renders ok in both cases since the complete vertical span cell fit within the remaining vertical space on that page.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant