Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QWebEnginePage's print preview (PrintPreviewDialog) is fuzzy



  • I'm working on a project using QWebEnginePage to print web page.

    When showing print preview by PrintPreviewDialog,the page content is fuzzy (zoom 100%),while if we use QTextEdit instead of QWebEnginePage to render the page content, the page preview in PrintPreviewDialog is clear, Could you give any suggestions to this issue.



  • Here is my code:

    paintRequested signal is connected to paint function:

    connect(&previewDialog, &QPrintPreviewDialog::paintRequested, this, &PrintHandler::paint);
    

    paint function

    void PrintHandler::paint(QPrinter *printer)
    {
        QEventLoop loop;
        bool result;
        auto cb = [&](bool success) {
            result = success;
            loop.quit();
        };
        m_webEngineView.page()->print(printer, std::move(cb)); // render the page content
        loop.exec();
        if (!result) {
           ...
        }
    }
    


  • Meet the same issue under Ubuntu 20.04 with Qt 5.15.2

    If we do not use PrintPreviewDialog, but print QWebEnginePage as PDF document directly, the resolution is correct as what we set in QPrinter.

    Ref: https://bugreports.qt.io/browse/QTBUG-78161



  • @HiMa
    I note that the bug ref you give was fixed as of 5.14.0 RC1, yet you say you see this in 5.15.2? I don't know how that relates to the OP's version. Are you saying the issue has not been resolved after all?


Log in to reply