4

I am using Wicked PDF that uses Wkhtmltopdf 0.9.9.1 via wkhtmltopdf-binary gem. I have a table as described below (simplified)

<div id="listing">
     <table>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
     </table>
</div>

and style as described below (simplified)

 <style>
    #listing table tr td {
        width:200mm !important
    }
    #listing {
        width:210mm;
        height:297mm;
        page-break-inside:auto;
    }
  </style>

Since the there are 4 cells, each 200mm in width, the table should overflow to the right of the container (container's width is A4 standard width = 210 mm )

Why is it that the table never gets broken into 2 pages? I have followed some links related to it, but still get no good progress. Is it the case that Wkhtmltopdf does not support page break for horizontal overflowing? I really appreciate for some pointers.

ADDED INFO:

The whole thing simply shrinks to fit the table (auto-scaled). When I added rule "overflow:hidden", the table gets cut-off without being continued to the next page.

The intended behavior is :

  1. When the table overflows vertically, table gets continued on the next page.
  2. When the table overflows horizontally, table gets continued on the next page.
  3. When the table overflows in both direction, table gets continued on the next pages. Which one comes first (overflowed right side or bottom side) is not important, as long as both extra will come in the following pages.

If Wkhtmltopdf is not the correct tool for this, I would be glad to know some workaround (if any) or to know the best tool for this. Thank you.

Zword
  • 6,605
  • 3
  • 27
  • 52
  • Does the table overflow from the page and get "cut off" or does the page shrink to fit the table? Forcing layouts like this with wkhtmtltopdf is freaking difficult and wkhtmltopdf is not a good tool for this. It's not an adobe tool :P. I would say that if you have a like a report or something that you are working on, either have your design flexible or use some other tool. – Joel Peltonen Feb 03 '14 at 07:32
  • When I enforce overflow:hidden then table gets cut off. When I remove the rule, the whole think simply shrinks to fit the table. What do you mean by leaving the design flexible? – Yudho Ahmad Diponegoro Feb 04 '14 at 02:04
  • 1
    I mean that if you have a design that is 100% the width of the page in 2 columns, simply do something else easier. The design as in how it looks. Like when you are designing a house, and find out that your original idea doesn't work because physics is all wrong - it might be easier to change your house design than physics. – Joel Peltonen Feb 04 '14 at 06:48
  • So in other words, if I know it will likely exceed the width, I can purposely break it? That makes sense..Thank you – Yudho Ahmad Diponegoro Feb 05 '14 at 12:50
  • Actually I would recommend that you simply always use percentages for widths. That way is very nice with wkhtmltopdf, but it prevents rigid layout designs. So; `#listing {width:100%;} table { width:90% !important; }` for example. – Joel Peltonen Feb 11 '14 at 10:24

1 Answers1

5

Try to upgrade your wktohtml to v0.12.0 because according this there is a lot of improvements on table page-break improvements:

  • [qt] prevent page breaks in table rows
  • [qt] repeat THEAD/TFOOT when table contains page breaks
  • [qt] various table page-break improvements
  • [qt] implement "page-break-inside: avoid" for non-floating block elements
Erik
  • 14,060
  • 49
  • 132
  • 218