Printing a QWebView doesn't seem to honour page breaks?



  • I assume I'm doing something wrong here. I wrote a simplified version of what I'm trying to do; load an HTML page into a QWebView, have a:

    @<p style="page-break-before:always;" />@

    ...which, as I understand it, should create proper page breaks.

    This works as expected when using Chromium and Firefox, but from my little program I'm not having any luck:

    @void WebkitPrintTest::loadPage()
    {
    ui->webView->load(QUrl("qrc:///webkit_print_test.html"));
    }

    void WebkitPrintTest::doPrint()
    {
    QPrinter *printer = new QPrinter();

    QPrintDialog printDialog(printer, ui->webView);
    printDialog.setWindowTitle("Printing Thing");
    
    if( printDialog.exec&#40;&#41; == QDialog::Accepted )
        ui->webView->print(printer);
    

    }
    @

    I've verified that the paragraph element is there, that the style includes the page-break-before: always attribute, and copying and pasting this into a file, loading in a browser, and printing, will properly insert page breaks.

    However, in my application, they are entirely ignored. The paragraph break is inserted, but not a page break. It prints fine besides this.

    I figure there's just an option that I need to enable? I'd rather not generate each page in a standalone QWebView if I can avoid it.



  • I would regard this a bug. Did you open an issue in the "public bugtracker":http://bugreports.qt-project.org already?



  • We've had the same issue since upgrading from 4.7.4 to 4.8.2...

    FYI: Printing QWebView with QPrinter::PdfFormat using CSS styles "page-break-before:always;" and "page-break-after:always;".

    EDIT: Bug Tracker - https://bugs.webkit.org/show_bug.cgi?id=89756


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.