[Qt-interest] Printing a (local) webpage with images

Mathias Waack Mathias.Waack at rantzau.de
Thu May 26 16:35:12 CEST 2011


Hi all, 

I'm trying to print a webpage. The problem is (at least from my understanding) 
this fact: 

[see QWebFrame::setContent]
The data is loaded immediately; external objects are loaded asynchronously.

If I print the page directly like this: 

QWebView *view = ...;
view->setHtml(... /* a QString containing some <img src="file://..."> tags*/);
QPrinter printer;
printer.setPageMargins(20,5,5,5,QPrinter::Millimeter);
printer.setOutputFileName(pdfFileName);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setPageSize(QPrinter::A4);
view.print(&printer);

in some cases some images are missing on the pdf. Thus I assume the problem is 
the above sentence. Even waiting for the "void loadFinished(bool ok)" signal 
does not solve my problem. 

I there a way to ensure all external objects in the page are loaded and the 
document is ready for printout? 

Thanks!

Mathias



More information about the Qt-interest-old mailing list