Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to print text on multiple pages?
I am trying to print the details of a form but I am not sure how to do it if the information needs to be split on multiple pages.
Am using QImage with QPainter to make a picture using drawText and then send it QPrinter to print it.
The issue is to make the entire QImage need to send to QPainter, I don't know how I can calculate QRect's height based on the QString provided.
Went with making a html document and simply printing that using WebEnginePage.
artwaw last edited by
First thing: why are you using QImage? You can just draw text on the Painter using drawText. This way is simpler - text will be divided into pages as it goes.
Apart from that you can request new page explicitly by calling printer.newPage().
With QImage things complicate a bit, since print size depends on image DPI and page DPI - you can either scale the image to fit certain size you have on the page or calculate the size using DPI of the image and DPI of a printer/page.
@artwaw Hi and thanks for answering,
To be honest that's what I thought to be the best course because I will also need add some small images inline with some of the text.
artwaw last edited by artwaw
I understand, will try to look into it in the nearest future, thank you very much.