QWebview, alignment issue while printing the content to the printer.
-
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 () != 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 ?
-
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!