How to prevent page break from splitting a cell and spanning it across two pages in the PDF?

(4 posts) (2 voices)

Tags:

No tags yet.

  1. Gondwana, Member

    I've tried adding a style sheet element of page-break-inside: avoid to the cell, the row, the table and the div. The cell and row had not impact. Adding it to the table or the div resulted in a page break before the table, but the rows were still split and span two pages.

    Is there an easy way to ensure a cell is not split across two pages in the PDF?

    I'm using wkhtmltopdf. This does seem to be a standing problem that wkhtmltopdf attributes to WebKit. page-break-.... seems to be discouraged for tables

    If the answer is to use dbr.purehtml, can you provide an example because just embedding a div inside the myDBR table cells doesn't seem to work.

  2. myDBR Team, Key Master

    You can try to put the the problematic column inside a DIV with a style "page-break-inside: avoid;" attached to the DIV.

    --
    myDBR Team

  3. Gondwana, Member

    Yeah. I already tried that by adding a class to the style sheet. It didn't work. So I thought I would try again by embedding the style element.

    Here is an example of the results from the unmodified code: https://www.dropbox.com/s/rfndl652j40slb9/BeforeMod.tiff

    You can see that even though the row is a single line, the row is clipped and a small portion of the text is placed on the following page.

    This is the code modifications to wrap all columns in <div>s:

    select 'dbr.colstyle', 'Low Prob.', '%.1f%%'; select 'dbr.colstyle', 'High Prob.', '%.1f%%'; select concat('dbr.purehtml:<div style="page-break-inside: avoid;">',r.Col1,'</div>') as 'Col 1', concat('dbr.purehtml:<div style="page-break-inside: avoid;">',r.Col1,'</div>') as 'Col 2', concat('dbr.purehtml:<div style="page-break-inside: avoid;">',r.Col3,'</div>') as 'Col 3', concat('dbr.purehtml:<div style="page-break-inside: avoid;">',r.Col4,'</div>') as 'Col 4', concat('dbr.purehtml:<div style="page-break-inside: avoid;">',r.Col5,'</div>') as 'Col 5', concat('dbr.purehtml:<div style="page-break-inside: avoid;">',r.Col6,'</div>') as 'Col 6', concat('dbr.purehtml:<div style="page-break-inside: avoid;">',r.Col7,'</div>') as 'Col 7', concat('dbr.purehtml:<div style="page-break-inside: avoid;">',r.Col8,'</div>') as 'Col 8', concat('dbr.purehtml:<div style="page-break-inside: avoid;">',r.Col9,'</div>') as 'Col 9'

    A snippet of the resulting PDF shows a change, but the issue persists. I am concerned that a line of text will be split down the middle and rendered unreadable: https://www.dropbox.com/s/l07v3mp7tbrw7jf/AfterMod.tiff

    Finally looking at the HTML, the <div> does not even make it into the HTML on all the columns: https://www.dropbox.com/s/52yvvhbuuy4axx4/AfterHTML.tiff

    Am I the only one who has problems with single line report rows being split onto two PDF pages? Have I done this to myself? If so are there some undocumented rules for the logo on the report header, or customizing the theme?

  4. myDBR Team, Key Master

    OK,
    you may encounter slight anomalies when wkthmltopdf is calculating on the page height, depending on your server / fonts / wkhtmltopdf version, but we have not seen cases where text is split down the middle.

    You can play around with wkhtml options by saving the output of the report using the "select 'dbr.export.options', 'debug', 1;" or try to increase table cell margin a bit using dbr.css.

    As for the <div> not being in all columns, most likely the data in column is null causing the result of concat being null.

    --
    myDBR Team


Reply

You must log in to post.