.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" style="width: 100%">
<tr>
td bgcolor="yellow">Hi i am just a String</td>
</tr>
</table></td>
<td>sdfsdf</td>
<td>sdfds</td>
</tr>
</table>
</body>
</html>
<!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" style="width: 100%">
<tr>
td bgcolor="yellow">Hi i am just a String</td>
</tr>
</table></td>
<td>sdfsdf</td>
<td>sdfds</td>
</tr>
</table>
</body>
</html>
To copy to clipboard, switch view to plain text mode
Here is my QT Code:
QPrinterprinter;
QWebSettings::globalSettings()->setAttribute(QWebSettings::PrintElementBackgrounds,true);
setAttribute(QWebSettings:rintElementBackgrounds, true);
settings()->setAttribute(QWebSettings::PrintElementBackgrounds,true);
settings()->setAttribute(QWebSettings::JavaEnabled,true);
settings()->setAttribute(QWebSettings::JavascriptEnabled,true);
settings()->setAttribute(QWebSettings::AutoLoadImages,true);
printer.setFontEmbeddingEnabled(true);
printer.
setOrientation(QPrinter::Portrait);
printer.setFullPage(true);
qDebug()<<" HoHoooo.. Going to print ";
if(dlog
->exec
()!=QDialog::Accepted) {
qDebug()<<"Printing Not accepted.. ";
}
else
{
page()->mainFrame()->print(&printer);
}
}
QPrinterprinter;
QWebSettings::globalSettings()->setAttribute(QWebSettings::PrintElementBackgrounds,true);
setAttribute(QWebSettings:rintElementBackgrounds, true);
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.setFullPage(true);
QPrintDialog*dlog=newQPrintDialog(&printer,this);
qDebug()<<" HoHoooo.. Going to print ";
if(dlog->exec()!=QDialog::Accepted)
{
qDebug()<<"Printing Not accepted.. ";
}
else
{
page()->mainFrame()->print(&printer);
}
}
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
Bookmarks