WicketPDF rendering table not aligned properly and footer place at last page

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 14:01:50

Page break issues can usually be mitigated with a few css rules, well placed:

div.alwaysbreak { page-break-before: always; }
div.nobreak:before { clear:both; }
div.nobreak{ page-break-inside: avoid;
  /* http://code.google.com/p/wkhtmltopdf/issues/detail?id=9#c21 */
}

So, one of the interesting things is that these rules don't work on table elements, so if you have a table and want to prevent cells from being split in half, you can wrap each table row with a <div>.

This is certainly not clean & semantic, but you can do it like this:

<table>
  <thead>
    <div class='nobreak'>
      <tr>
        <th>One</th><th>Two</th>
      </tr>
    </div>
  </thead>
  <tbody>
    <div class = 'nobreak'>
      <tr>
        <td>Uno</td><td>Dos</td>
      </tr>
    </div>
  </tbody>
</table>

To get your page borders to line up perfectly, you are probably going to have to set it to a fixed height with CSS with an .awaysbreak, then have some javascript that computes the height of the table and breaks it into chunks based on height.

Maybe it's just because your table so far is so simple, but this looks like it might be a good candidate to try using prawn with. You'll have better control of those types of layout issues.

There's a railscast for it here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!