[Qt-interest] adding header/footer to PRINTED QWebFrames?

Giuseppe D'Angelo dangelog at gmail.com
Mon Jun 1 23:27:03 CEST 2009


On Mon, Jun 1, 2009 at 11:12 PM, Paul Miller <paul at fxtech.com> wrote:
> I have a QWebFrame with some HTML content and I want to add page numbers
> and some header/footer info when it is printed.
>
> Is this possible?

AFAIK there is not an API for doing that, see also
http://www.qtsoftware.com/developer/faqs/is-it-possible-to-set-a-header-and-footer-when-printing-a-qtextdocument
http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=115739

What I would do in this case is to hack a bit QPrinter sources
and exposing QPrinterPrivate::setPreviewMode, then printing normally, and then
retrieve a list of QPictures with QPrinterPrivate::previewPages
(see what QPrintPreviewDialog does).

Since QPicture is a QPaintDevice,
you can paint over them (and add headers/footers) with a QPainter.

Then you can disable the preview mode and print the modified QPictures.

-- 
Giuseppe D'Angelo



More information about the Qt-interest-old mailing list