QWebView printing cut text in half
-
I'm trying to print a HTML page from QWebView and it's works mostly. But page breaks are problem. Page breaks are not displayed right in multi page text. Text are cut in half in page break; first half is displayed in the first page and last half in the next page. How I can prevent it?
Here is the code:
@void printui::printTest()
{
webView = new QWebView();
QString path = "C:/tmp/demo.html";
connect(webView,SIGNAL(loadFinished(bool)),this,SLOT(loadFinished()));
webView->load(QUrl(path));}
void printui::loadFinished()
{
QPrinter printer;
printer.setPaperSize(QPrinter::A4);
printer.setOrientation(QPrinter::Portrait);
printer.setPageMargins(10,10,10,10,QPrinter::Millimeter);
QPrintPreviewDialog ppd = new QPrintPreviewDialog(&printer);
connect(ppd,SIGNAL(paintRequested(QPrinter)),this,SLOT(printRequestTest(QPrinter*)));
ppd->exec();
}void printui::printRequestTest(QPrinter *p)
{
webView->print(p);
}
@Result:
This is Qt 4.8.3 and Windows 7