[webkit-gtk] Alternative to page-break-*

Thiago Bellini Ribeiro hackedbellini at gmail.com
Wed Aug 22 06:06:21 PDT 2012


Hi List,

I'm a developer of Stoq project[1], an open source erp system
developed in python/gtk.
We used to generate our reports using reportlab, but we are trying to
migrate them to html so it's easier to maintain.

At first, we tried xhtml2pdf[2], but it misses a lot of css tags and
it renders very different than browsers, making it a not good
alternative.

We decided than to use webkitgtk to render and than export to a pdf
and send it to printoperation. Works perfect, with one exception, the
page-break-* css tags.

For example. I have a div that can't can printed half on one page and
half on another. Googling I found that I should use
'page-break-inside: avoid' to do that, but neither webkit itself
(webkitgtk is a fork of it, right?) does that, testing in chromium for
example.

I found a workaround that worked for chromium, that is to put an empty
div with 'page-break-after: always' or 'page-break-before: always'
where I want it to break. But that didn't work on webkitgtk (testing
on my implementation and on epiphany too).

To workaround that, I had to define a height for those divs so they
fit ok on an A4 page without breaking information on half. But that's
not the best alternative, as any small change, like a font change will
make me have to recalculate the divs height and etc. And not to say
that the lack of that advanced print control will difficult to
implement some tabular information that we haven't tried to start the
migraion yet.

The question is..is there any alternative on webkitgtk to work around
that? Maybe a way of patching webkitgtk inside my app to support one
of those tags (if it was python, I would be looking for a way of
monkey-patching it until the bug is solved, but since it's c++ I don't
know if that's possible)? Or something else?

Any suggestions are very welcome. I don't understand a lot of html/css
development, so I'm very lost for not being able to use any solution I
found on the web. And I googled a lot! :P

[1] http://www.stoq.com.br/
[2] http://www.xhtml2pdf.com/

Thanks in advance,

-- 
Thiago Bellini | http://hackedbellini.org

“Real knowledge is to know the extent of one's ignorance.” - Confucius


More information about the webkit-gtk mailing list