Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-59682

Right side of HTML document is truncated when printed with QPrinter and QWebView

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 4.8.2, 4.8.4, 4.8.5, 4.8.7, 4.8.x
    • Fix Version/s: None
    • Component/s: GUI: Printing, WebKit, WebView
    • Labels:
      None
    • Environment:
      qt-opensource-windows-x86-mingw482-4.8.7 on Windows 7 64 Bit with Qt Creator

      Description

      Since my update from Qt 4.7.4 to Qt 4.8.7 it isn't possible for me to print a simple HTML table without cutting off the right side. Here is the code that shows a HTML table in the QPrintPreviewDialog:

          QApplication a(argc, argv);
      
          QWebView *webView = new QWebView();
          webView->load(QUrl("table.html"));
      
          QPrinter *printer = new QPrinter();
          printer->setPaperSize(QPrinter::A4);
      
          QPrintPreviewDialog *printPreview = new QPrintPreviewDialog(printer);
          QObject::connect(printPreview, SIGNAL(paintRequested(QPrinter*)), webView, SLOT(print(QPrinter*)));
      
          a.processEvents();
          printPreview->show();
      
          return a.exec();
      

      I attached the HTML table to reproduce this problem and an screenshot of the issue. I think this problem occurs since QtWebkit 2.x. Is there a workaround?

      Edit: This problem is not only related to HTML tables. If you use a <p>-tag with a long string, then it will be also truncated. And the bug occurs on every page, not only on the first one. I'm writing this, because I saw a similar bug report, but there was only the first page affected (https://bugreports.qt.io/browse/QTBUG-30621).

      Edit2: So far I found the bug in the following Qt versions: 4.8.2, 4.8.4, 4.8.5, 4.8.7

        Attachments

        1. qwebview bug.jpg
          qwebview bug.jpg
          58 kB
        2. table.html
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            johnlayt John Layt
            Reporter:
            piotr_s piotr_s
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes