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

QWebView will not print text past the first page

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.4.1
    • None
    • Windows 8.1, Qt 4.5.1 community edition, MSVC 2013.

    Description

      When I try to use a QWebView to load a simple HTML table with text only, the content looks fine on screen. But if I try to print it, two things happen:

      • The text does not stay within the table frame
      • The text stops printing past the first page (the table frame does print, just not the text)

      I'm attaching a pdf with the result of printing. This short, complete program reproduces the problem easily:

      #include <QApplication>
      #include <QPrinter>
      #include <QPrintDialog>
      #include <QWebView>
      
      // Create an HTML table with the given dimensions
      static QString htmlTable(int nrows, int ncols) {
          QStringList rows;
          for (int r=0 ; r<nrows ; ++r) {
              QStringList cols;
              for (int c=0 ; c<ncols ; ++c) {
                  const char colChar = 'A' + c;
                  cols.append(QString("<td>%1%2</td>").arg(colChar).arg(r+1));
              }
              rows.append(QString("<tr>%1</tr>\n").arg(cols.join("\n  ")));
          }
          return QString("<table border=\"1\">%1</table>\n").arg(rows.join("\n "));
      }
      
      // To be compiled with modules: core gui printsupport webkitwidgets
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QPrinter printer;
          if (QPrintDialog(&printer).exec() == QDialog::Accepted) {
              QWebView wv;
              wv.setHtml(htmlTable(100,10));
              wv.print(&printer);
          }
          return 0;
      }
      

      Attachments

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

        Activity

          People

            johnlayt John Layt
            pablodiazgutierrez Pablo Diaz-Gutierrez
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes