.Hi all,

Your advice will be really appreciatible.

I am doing the following:

I have a class derived from QWebView, and trying to pass the View to the printer.

My HTML Code:

Qt Code:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  5. <title>I am a title</title>
  6. </head>
  7. <body>
  8. <label> i am a label</label>
  9. <br>
  10. <br>
  11. <table border="8px">
  12. <tr>
  13. <td bgcolor="red">add</td>
  14. <td>asd</td>
  15. <td>dfs</td>
  16. <td>sdfds</td>
  17. </tr>
  18.  
  19. <tr>
  20. <td>sdfds</td>
  21. <td><table border="2px" bgcolor="green" style="width: 100%">
  22. <tr>
  23. td bgcolor="yellow">Hi i am just a String</td>
  24. </tr>
  25. </table></td>
  26. <td>sdfsdf</td>
  27. <td>sdfds</td>
  28. </tr>
  29.  
  30. </table>
  31.  
  32. </body>
  33. </html>
To copy to clipboard, switch view to plain text mode 

Here is my QT Code:

Qt Code:
  1. QPrinterprinter;
  2.  
  3. QWebSettings::globalSettings()->setAttribute(QWebSettings::PrintElementBackgrounds,true);
  4. setAttribute(QWebSettings:rintElementBackgrounds, true);
  5. settings()->setAttribute(QWebSettings::PrintElementBackgrounds,true);
  6. settings()->setAttribute(QWebSettings::JavaEnabled,true);
  7.  
  8. settings()->setAttribute(QWebSettings::JavascriptEnabled,true);
  9. settings()->setAttribute(QWebSettings::AutoLoadImages,true);
  10.  
  11. printer.setFontEmbeddingEnabled(true);
  12. printer.setPageSize(QPrinter::A4);
  13. printer.setOrientation(QPrinter::Portrait);
  14. printer.setFullPage(true);
  15.  
  16. QPrintDialog*dlog=newQPrintDialog(&printer,this);
  17.  
  18. qDebug()<<" HoHoooo.. Going to print ";
  19. if(dlog->exec()!=QDialog::Accepted)
  20. {
  21. qDebug()<<"Printing Not accepted.. ";
  22. }
  23. else
  24. {
  25. page()->mainFrame()->print(&printer);
  26. }
  27. }
To copy to clipboard, switch view to plain text mode 


PROBLEM:

The output is displayed properly in the QWebView Page, but while printing, the text alignment going for a toss.

Kindly suggest if i missed out something or need to add more ?..

Also, i am not sure if the above problem relates to this issue ?

https://bugreports.qt-project.org/browse/QTBUG-29959