I have a HTML document which consists of a succession of divs, some of which may contain images. I want to export the document as pdf. For this I am using QPrinter and QWebView combination. It prints fine, but but pages are 'broken` at regular intervals, mostly whenever page is about to exceed A4 size. In contrast, say if I use phantomjs and rasterize.js combo, it prints out the entire HTML in one long single page in the PDF document.

How do I achieve the same in QPrinter as well? I tried adding media queries like page-break-inside: avoid, doesn't work.