Hi
I'm using QTextEditor to format text for printing. After that I'm sending this text as html QString to print method.
On PrintButton click: emit signal_PrintFormatedText(htmlText);

Inside print method I have:

Qt Code:
  1. QPrinter printer;
  2. printer.setOutputFormat(QPrinter::NativeFormat);
  3. printer.setDuplex(QPrinter::DuplexAuto);
  4. printer.setColorMode(QPrinter::GrayScale);
  5.  
  6. QPainter painter(&printer);
  7.  
  8. doc.documentLayout()->setPaintDevice(painter.device());
  9. doc.setHtml(htmlFormatedText);
  10.  
  11. QSizeF paperSize;
  12. paperSize.setWidth(printer.width());
  13. paperSize.setHeight(printer.height());
  14. doc.setPageSize(paperSize);
  15.  
  16. doc.drawContents(&painter);
To copy to clipboard, switch view to plain text mode 

On first time (first printing) everything works fine. Problem is when I press PrintButton (in my app) once again. Printer prints some junk characters instead of first line of document.
What is the problem? How to fix it?