Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. QWebview, alignment issue while printing the content to the printer.
Forum Updated to NodeBB v4.3 + New Features

QWebview, alignment issue while printing the content to the printer.

Scheduled Pinned Locked Moved Qt WebKit
3 Posts 3 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jelari
    wrote on last edited by
    #1

    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:

    @<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>I am a title</title>
    </head>
    <body>
    <label> i am a label</label>
    <br>
    <br>
    <table border="8px">
    <tr>
    <td bgcolor="red">add</td>
    <td>asd</td>
    <td>dfs</td>
    <td>sdfds</td>
    </tr>

    <tr>
    <td>sdfds</td>
    <td><table border="2px" bgcolor="green" >
    <tr>
    td bgcolor="yellow">Hi i am just a String</td>
    </tr>
    </table></td>
    <td>sdfsdf</td>
    <td>sdfds</td>
    </tr>

    </table>

    </body>
    </html>@

    Here is my Qt Code:

    @ QPrinter printer;

     settings()->setAttribute(QWebSettings::PrintElementBackgrounds, true);
     settings()->setAttribute(QWebSettings::JavaEnabled, true);
     settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
     settings()->setAttribute(QWebSettings::AutoLoadImages, true);
    
      printer.setFontEmbeddingEnabled(true);
      printer.setPageSize(QPrinter::A4);
      printer.setOrientation(QPrinter::Portrait);
      printer.setResolution(QPrinter::ScreenResolution);
      printer.setFullPage(true);
    
    
    
    
      QPrintDialog *dlog = new QPrintDialog (&printer, this);
    
      qDebug () <<" Printing... ";
    
      if ( dlog->exec &#40;&#41;  != QDialog::Accepted)
      {
          qDebug () <<"Printing Not accepted.. :( ";
    
      }
      else
      {
    
          page()->mainFrame()->print(&printer);
    
      }
    

    }@

    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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mar91
      wrote on last edited by
      #2

      I have the same problem!
      Let's find a workaround!
      http://qt-project.org/forums/viewthread/32643/

      My workaround consist on saving the rendereded HTML to image. But i am blocked in printing the image!

      1 Reply Last reply
      0
      • O Offline
        O Offline
        ObiWan
        wrote on last edited by
        #3

        I have the same problem, too.
        I am using:
        Win7 x64
        Qt 5.1 (x32, x64)

        Apparently QWebView has a problem with <TABLE> tag in Qt5.1.
        My program works fine with Qt 4.8.4.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved