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

Wrong font size when printing from QWebView

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • None
    • 4.4.3, 5.4.2
    • None

    Description

      When printing the content of a QWebView to a regular laser printer, fonts appear slightly smaller than they should.

      // Test case
      // ------------------------------------
      #include <QtGui>
      #include <QtWebKit>

      int main(int argc, char** argv)
      {
      QApplication app(argc, argv);

      QString html;
      html += "<html><head>\n";
      html += "<style type=\"text/css\">\n";
      html += "<!--\n";
      html += "h1

      {\n"; html += " font-family:Arial,sans-serif;\n"; html += " font-size:1in;\n"; html += "}

      \n";
      html += "-->\n";
      html += "</style>\n";
      html += "</head><body>";
      html += " <h1>This should be 1 inch high.</h1>\n";
      html += "</body></html>";

      QWebView view;
      view.setHtml(html);
      QPrinter printer(QPrinterInfo::defaultPrinter(), QPrinter::HighResolution);
      QPrintPreviewDialog dialog(&printer);
      dialog.connect(&dialog, SIGNAL(paintRequested(QPrinter*)), &view, SLOT(print(QPrinter*)));
      dialog.exec();
      return 0;
      }
      // ------------------------------------

      Attachments

        1. document.html
          0.9 kB
          Stefan Schweitzer
        2. loadfinishedguard.h
          0.6 kB
          Stefan Schweitzer
        3. main.cpp
          1 kB
          Stefan Schweitzer
        4. printed_by_google_chrome.pdf
          103 kB
          Stefan Schweitzer
        5. printed_by_internet_explorer.pdf
          37 kB
          Stefan Schweitzer
        6. printed_using_qwebview_to_pdf.pdf
          12 kB
          Stefan Schweitzer
        7. size_of_images_relative_to_text_size.png
          41 kB
          Maurice van der Pot
        8. webviewfontsize.pro
          0.1 kB
          Stefan Schweitzer

        Issue Links

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

          Activity

            People

              Unassigned Unassigned
              admin Administrator
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes