Hi,

The following code results in an empty pdf file whereas when I show() the component, the html code displays correctly.
Any idea?

Here is the source:

Qt Code:
  1. #include <QtCore>
  2. #include <QtGui>
  3. #include <QtWebKit>
  4.  
  5.  
  6. int main(int argc, char *argv[]) {
  7. QApplication app(argc, argv, 1);
  8.  
  9. QPrinter *qPrinter = new QPrinter(QPrinter::HighResolution);
  10. qPrinter->setOutputFormat(QPrinter::PdfFormat);
  11. qPrinter->setOutputFileName("out.pdf");
  12.  
  13. QFile file("in.txt");
  14. if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
  15. return 1;
  16.  
  17. QString text;
  18. while (!file.atEnd()) {
  19. text += file.readLine();
  20. }
  21.  
  22. QWebView *qWebView = new QWebView();
  23. qWebView->setMinimumSize(1024,768);
  24. qWebView->show();
  25. qWebView->setHtml(text);
  26. qWebView->show();
  27. qWebView->print(qPrinter);
  28. return app.exec();
  29. }
To copy to clipboard, switch view to plain text mode 

The file in.txt contains only:
Qt Code:
  1. <html>
  2. <body
  3. helloWorld
  4. </body>
  5. </html>
To copy to clipboard, switch view to plain text mode 

Thanks for your help.
Best regards,
Oscar