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:
#include <QtCore>
#include <QtGui>
#include <QtWebKit>
int main(int argc, char *argv[]) {
qPrinter
->setOutputFormat
(QPrinter::PdfFormat);
qPrinter->setOutputFileName("out.pdf");
return 1;
while (!file.atEnd()) {
text += file.readLine();
}
QWebView *qWebView = new QWebView();
qWebView->setMinimumSize(1024,768);
qWebView->show();
qWebView->setHtml(text);
qWebView->show();
qWebView->print(qPrinter);
return app.exec();
}
#include <QtCore>
#include <QtGui>
#include <QtWebKit>
int main(int argc, char *argv[]) {
QApplication app(argc, argv, 1);
QPrinter *qPrinter = new QPrinter(QPrinter::HighResolution);
qPrinter->setOutputFormat(QPrinter::PdfFormat);
qPrinter->setOutputFileName("out.pdf");
QFile file("in.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return 1;
QString text;
while (!file.atEnd()) {
text += file.readLine();
}
QWebView *qWebView = new QWebView();
qWebView->setMinimumSize(1024,768);
qWebView->show();
qWebView->setHtml(text);
qWebView->show();
qWebView->print(qPrinter);
return app.exec();
}
To copy to clipboard, switch view to plain text mode
The file in.txt contains only:
<html>
<body
helloWorld
</body>
</html>
<html>
<body
helloWorld
</body>
</html>
To copy to clipboard, switch view to plain text mode
Thanks for your help.
Best regards,
Oscar
Bookmarks