Can WebKit avoid breaking block element while printing?
I’m in a fairly unique position in that I use WebKit to generate PDFs[1]. For the most part it works great but one area it has disappointed is when the resulting PDF is more than 1 page. There just doesn’t seem to be that much control in WebKit’s rendering of HTML and CSS to suggest when a page should break.
For example at the bottom of my default invoice design I have the business and client contact info. For most invoices everything fits on one page but if there are a lot of line items the address will be pushed on to the second page.

It would be great if I could find a way to tell WebKit that it should avoid breaking these DIVs when it prints. In fact I think such a thing is present in the CSS spec and if it worked it might look something like:
div.contact_info
{
page-break-inside: avoid;
}
Perhaps I’m doing something wrong, or maybe Safari just doesn’t implement this CSS attribute yet. If anyone out there has any suggestions or can forward this to someone who might I’d be very thankful.
[1]: The invoice (with the help of MGTemplateEngine) comes up with an HTML representation. That HTML is put into an off-screen WebView; which is then handed off to the print system; which generates a PDF; which is then stored in the ProfitTrain database.
Update: Here is a WebKit bug report that discusses the issue. (Thanks @chucker.)
Update 2: And my own formal bug report request for implementation.
Posted on: February 21, 2010 – 3:33 PM

Post a Comment | Comment RSS feed