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

QTextTable empty headers on pdf export, when sets QTextTableFormat::setHeaderRowCount and tables is in different QTextFrames.

    XMLWordPrintable

Details

    • 83dccf00ccf75da27551b68652d5c3c1b4f7ebff (qt/qtbase/5.13)

    Description

      ***************************************************************************************************************

      I have an issue with printing my tables into pdf using QTextDocument print function. In my example I use QPrinter, but result the same on different methods of printing(QPainter etc.).
      So let me explain my issue step by step:
      1) I create empty QTextDocument.
      2) In root QTextFrame (that I get using rootFrame function from QTextDocument), I insert 3 text frames one by one (using QTextCursor insertFrame)
      3) I insert QTextTables into each 3 frame (using QTextCursor insertTable)
      3.1) I set QTextTableFormat for each tables with atributes setHeaderRowCount(1) that will automaticaly repead me first row in each page on printing.
      4) I print this into pdf document;

      Expectation:
      When my tables are not fit into page, they divided and repeads first row correctly on each tables breaks.

      Actual result:
      When my tables are not fit into page, they divided and first row repeads correctly only for first table in first frame. The other two are repeads with blank spaces instead of header row, or paint two headers on on top of another. (Please see attached results PDF).

      ***************************************************************************************************************

      My investigation:

      I debug a little, and looks like the issue starts from this method:

      948 void QTextDocumentLayoutPrivate::drawFrame(const QPointF &offset, QPainter *painter,
      949 const QAbstractTextDocumentLayout::PaintContext &context,
      950 QTextFrame *frame) const

      When it starts to call this method:

      1215 void QTextDocumentLayoutPrivate::drawFlow(const QPointF &offset, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context,
      1216 QTextFrame::Iterator it, const QList<QTextFrame *> &floats, QTextBlock *cursorBlockNeedingRepaint) const

      And it call QTextDocumentLayoutPrivate::drawFrame again, in some moment of recursion the "const QPointF &offset" become wrong number.

      ***************************************************************************************************************

      Also I attached small examle where this issue reproduced.

      Attachments

        1. PrintToQPrintPreviewWidget.zip
          10 kB
        2. qtbug59000.tgz
          0.7 kB
        3. QTextDocumentPrintIssue.zip
          10 kB
        4. Results Of PDF Printing.zip
          412 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vgt Eirik Aavitsland
            AndriySlisarchuk Andriy Slisarchuk
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes