Variable page height with wkhtmltopdf

odoo, webkit, wkhtmltopdf

Solution

I would suggest taking a look at: https://github.com/AAverin/JSUtils/tree/master/wkhtmltopdfTableSplitHack

From what I understand, you would only need to define a specific class to your HTML table element, and the JS script would do the rest.

Also, you might want to look at theses (which eventually lead me to the first link)

- https://gist.github.com/niflostancu/3683510

- https://gist.github.com/bluntelk/5573089

Problem

I'm trying to print various receipts using wkhtmltopdf (using the webkit reporting tool in openERP). I have a receipt printer that has a continuous roll of paper. The printer automatically cuts the paper on a page break. This works great on receipts where the height of the "page" is always the same, but I can't figure out how to set the height dynamically on individual pages. Ideally I want to put a `page-break-after:always` css command after every receipt and for wkhtmltopdf to set the height of the page to match the height of the content. I'm guessing the only way is to hack the source code on https://github.com/antialize/wkhtmltopdf but hoping someone has already solved this problem.

Original source