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

Atlant Schmidt aschmidt at dekaresearch.com
Thu May 26 18:39:38 CEST 2011


Mathias:

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

  I think that in the most-general sense, there
  isn't a solution to this problem. Consider, for
  example, a web page that has a JavaScript running
  on it that rotates among multiple images.  Or an
  Ajax page that is busily doing something "out in
  the cloud" after the page has ostensibly "finished
  loading"; that page may continue to change as
  asynchronous results arrive from the cloud.

  That doesn't mean you can't solve your problem for
  your specific case, but I do think the problem isn't
  soluble in the fully-general case.

                       Atlant

-----Original Message-----
From: qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com [mailto:qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com] On Behalf Of Mathias Waack
Sent: Thursday, May 26, 2011 10:35
To: qt-interest at qt.nokia.com
Subject: [Qt-interest] Printing a (local) webpage with images

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
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest

This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.

Thank you.

Please consider the environment before printing this email.



More information about the Qt-interest-old mailing list