Hi,
I'm trying to print a QWebview before it is showed in the Dialog
QString html
= getHtmlString
();
// Get the HTML String ui.webView->setHtml(html); // set the Html string to the QWebView
printer.
setOutputFormat(QPrinter::PdfFormat);
printer.
setOrientation(QPrinter::Landscape);
if(fileName.length()>0 ){
printer.setOutputFileName(fileName);
ui.webView->print(&printer); // print the QWebview
}
QString html = getHtmlString(); // Get the HTML String
ui.webView->setHtml(html); // set the Html string to the QWebView
QPrinter printer; // Create the Printer
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setPageSize(QPrinter::A4);
printer.setOrientation(QPrinter::Landscape);
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),QCoreApplication::applicationDirPath(),tr("*.pdf"));
if(fileName.length()>0 ){
printer.setOutputFileName(fileName);
ui.webView->print(&printer); // print the QWebview
QDesktopServices::openUrl(QUrl(fileName));
}
To copy to clipboard, switch view to plain text mode
The printed html pdf is always white.
If I print the webview by pressing a button after it has been shown on the Dialog there's text in the pdf.
Can anyone help me?
Thanks,
Grisu
Bookmarks