pkj
13th March 2011, 14:17
Hi,
I am trying to print webview to a pdf page. At the loadFinished() signal of webview object, I do the following:
void W_Test::loadFinished()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Choose existing file or type in new file name"),
QString(), tr("Excel files (*.pdf)"));
if(fileName.isEmpty()) return;
QPrinter printer;
printer.setOrientation(QPrinter::Landscape);
printer.setPaperSize(QPrinter::A4);
printer.setFullPage(true);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(fileName);
printer.setFromTo(1,1);
webView->print(&printer);
}
However i get QPainter::begin() : returned false message once in a while. Otherwise works like a charm...!!
My guesses are qwebview never emits loadFinished signal... but QPainter::begin() message shouldn't have come then. ??..
I am trying to print webview to a pdf page. At the loadFinished() signal of webview object, I do the following:
void W_Test::loadFinished()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Choose existing file or type in new file name"),
QString(), tr("Excel files (*.pdf)"));
if(fileName.isEmpty()) return;
QPrinter printer;
printer.setOrientation(QPrinter::Landscape);
printer.setPaperSize(QPrinter::A4);
printer.setFullPage(true);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(fileName);
printer.setFromTo(1,1);
webView->print(&printer);
}
However i get QPainter::begin() : returned false message once in a while. Otherwise works like a charm...!!
My guesses are qwebview never emits loadFinished signal... but QPainter::begin() message shouldn't have come then. ??..