WicketPDF rendering table not aligned properly and footer place at last page
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.
WeasyPrint: fixed footer tag overlapped by long table on each pdf page
I found a solution for it.
First of all you've to define your page margins:
@page {
size: A4;
margin: 15mm 20mm;
}
I've a top & bottom margin of 15mm.
When you now place a fixed footer in the page/body, it will be "inside" these margins and non-fixed
elements will overlap it. So what you want to do is moving the fixed footer "outside" of these margins:
footer
{
position : fixed;
right : 0;
bottom : 0;
margin-bottom : -10mm;
height : 10mm;
text-align : right;
font-size : 10px;
}
The fixed
and bottom
properties will place your footer on every page on the bottom, but within the defined margins (where it is overlapped). The height
specifies the footer height, which is then moved "outside" the margins by the negative margin-bottom
property. Just make sure that margin-bottom
>= height
.
Cheers
Domi
avoid page break inside row of table
You might try this with CSS:
<table class="print-friendly">
<!-- The rest of your table here -->
</table>
<style>
table.print-friendly tr td, table.print-friendly tr th {
page-break-inside: avoid;
}
</style>
Most CSS rules don't apply to <tr>
tags directly, because of exactly what you pointed out above - they have a unique display
style, which doesn't allow for these CSS rules. However, the <td>
and <th>
tags within them usually do allow this kind of specification - and you can easily apply such rules to ALL child-<tr>
's and <td>
's using CSS as shown above.
Related Topics
Embed a JavaScript Engine in an iOS Application
How to Listen for Keyboard Open/Close in JavaScript/Sencha
Ruby Array to JavaScript Array
Finding Variable Type in JavaScript
Jqgrid, How to Make a Column Editable in the Add Dialog But Not During (Inline) Edits
Angular 4 Interceptor Retry Requests After Token Refresh
Sorting a JSON Object in JavaScript
Format a Number as 2.5K If a Thousand or More, Otherwise 900
How to Get the Nth Occurrence in a String
Jquery Scrolltop() Doesn't Seem to Work in Safari or Chrome (Windows)
How to Convert Special Utf-8 Chars to Their Iso-8859-1 Equivalent Using JavaScript
How to Parse JavaScript Using Nokogiri and Ruby
How to Preview Uploaded Image Instantly with Paperclip in Ruby on Rails
Detect If Hovering Over Element with Jquery
How to Reduce JavaScript Object to Only Contain Properties from Interface
Detect If Hovering Over Element with Jquery