qtqwebviewqwebkitqprinter

Print error on page (qtWebkit)


Bug in Qt5.2.1:

The only problem was corrected in QPrintPreviewDialog but when the print is printed on paper the failure still exists.

With QPrintPreviewDialog pages work perfect, but on "paper" (printed in paper) from second page (in other words all pages except the first occur the BUG) "texts" and "images" (non-background) disappear (apparently the fault only occurs with inline elements).

See: https://bugreports.qt.io/browse/QTBUG-37240 (see the attachments to a test-case)


Bug in Qt5.0.1, Qt5.0.2 and Qt5.1.0

The first page of the print out of a QWebView with small fonts and images.

Apparently the problem only occurs with inline elements (texts and images).

Note: The error occurs in Windows XP, Windows 7, Window 7 x64, Mac OS X 10.8.3

[edit]

Source-html: http://jsfiddle.net/bdm6Y/2/

Frame content: http://jsfiddle.net/bdm6Y/2/show/

ErrorPrint

Source:

QPrinter p;
p.setPaperSize(QPrinter::A4);
p.setFullPage(true);
p.setResolution(300);
p.setOrientation(QPrinter::Portrait);

QPrintPreviewDialog preview(&p);
preview.setWindowTitle(ui->myWebView->page()->mainFrame()->title());
connect(&preview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(printPreview(QPrinter*)));
preview.exec();

...

void printPreview(QPrinter *printer) {
    ui->myWebView->print(printer);
}

I do not know if this is a bug or something I did wrong, what could it be?

Thanks!

[edit]

QT bug reports:

https://bugreports.qt.io/browse/QTBUG-30621


Solution

  • Problem fixed in Qt5.3

    Qt 5.3 Print Support

    Code tested in Windows:

    QPrinter print(QPrinter::HighResolution);
    print.setPageMargins(qreal(1), qreal(1), qreal(1), qreal(1), QPrinter::Millimeter);
    print.setPaperSize(QPagedPaintDevice::A4);
    
    QPrintPreviewDialog pd(&print, mwindow, Qt::Window);
    QObject::connect(&pd, SIGNAL(paintRequested(QPrinter *)), this, SLOT(preview(QPrinter *)));
    if(pd.exec() == QPrintPreviewDialog::Accepted) {
        /*something*/
    }
    
    ...
    
    void MainWindow::preview(QPrinter* p) {
        mframe->print(p);//mframe is an QWebFrame
    }