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.Any ideeas?
-
@adutzu89 Hi.
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.