Important: Please read the Qt Code of Conduct -

[SOLVED] How to make a division between pages in a PDF?

  • Hi everyone!

    In my application I need to create PDF report. To do this I'm using QWebView and QPainter. This two classes work perfect. I'm creating HTML content and then render it using QWebView. When this content will rendered in QWebView I've printing it to QPainter instance. This generated PDF file with multiple pages. But I need to create document with few sections. Every new section must starts with new page. How I can do this with HTML + QWebView + QPainter? Or I can use something else to generate PDF file.

    Thanks for the help!

  • Web technology isn't really suitable for rendering on a paginated canvas. It is really aimed at rendering on a single big page.

    We looked into using HTML for creating reports in our application, and decided against it for mainly this reason. When generating a print, you can normally use QPrinter::newPage(), but I did not find a sane way to do that inside HTML based reports.

  • Thank for the reply!

    I will search more solutions for this problem. If I will find solution I will post it here.

  • Hi everyone!

    At last I've solved my problem with PDF. I'm using JavaScript to calculate top margin for every section which must start from new page.

Log in to reply