PDA

View Full Version : QWebView print to PDF and add background image



supergillis
9th September 2010, 13:02
Hello,

I am currently doing a summer job and I have to make some sort of WYSIWYG editor.

I managed to make the editor. I want to export the content (in HTML format) to PDF and put a background image on the first page. Exporting to PDF works like a charm but I don't know how to put a background image on the first page...

This is what I got so far:

QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setPaperSize(QPrinter::A4);
printer.setOutputFileName("html.pdf");

m_view->setHtml(html);
m_view->show();
m_view->print(&printer);

But then I try to add, for example, a rectangle:

QPainter painter(&printer);
painter.setBrush(Qt::red);
painter.drawRect(10, 10, 100, 100);
painter.end();
This overwrites the previous painter...

Should I make a new QPaintEngine? Or what should I do?

Thanks in advance!
Gillis