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

QPrintPreviewDialog + QWebView print wrongly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 5.0.1
    • GUI: Printing, WebKit
    • None
    • It happen both on Linux and Windows

    Description

      When use QPrintPreviewDialog it shows wrongly painted webpage content (wrong layouts, buttons without text, page cutted and so one), the problem is somethere related to QPicture pages in QPrinter. Try to print almost any page webpage (for example wikipedia) to see the problem (or see attachment).

      I found a way to fix this, but on qtwebkit side, by making QPicture for each page and draw it in QPrinter painter then. The following changes in QtWebkit code (qwebframe.cpp) fixes that wrong printing:

      @@ -879,7 +881,17 @@

      printer->printerState() == QPrinter::Error) { return; }
      • printContext.spoolPage(page - 1, pageRect.width());
        +
        + QPicture pagePicture;
        + QPainter pagePainter;
        + pagePainter.begin(&pagePicture);
        + pagePainter.setRenderHints(QPainter::Antialiasing
      QPainter::TextAntialiasing QPainter::SmoothPixmapTransform QPainter::HighQualityAntialiasing);
      + pagePainter.scale(zoomFactorX, zoomFactorY);
      + QtPrintContext pagePrintContext(&pagePainter, pageRect, d);
      + pagePrintContext.spoolPage(page - 1, pageRect.width());
      + pagePainter.end();
      + painter.drawPicture(0, 0, pagePicture);
      +
      if (j < pageCopies - 1)
      printer->newPage();
      }

      Attachments

        1. qprintpreview_broken.png
          158 kB
          Mozhaev Grigory
        2. qprintpreview_fixed.png
          196 kB
          Mozhaev Grigory

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              mibrunin Michael Bruning
              zcrendel Mozhaev Grigory
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes