QWebView print
-
Hi
I'm trying to print a web page from QWebView.view = new QWebView(this); QString html = cFile->pdfDocSell(NUM); //get html view->setHtml(html); printer = new QPrinter(); printer->setPageSize(QPrinter::A4); printer->setPageOrientation(QPageLayout::Portrait); printer->setPageMargins(15.00, 10.00, 7.00, 15.00, QPrinter::Millimeter); printer->setResolution(QPrinter::HighResolution); printer->setFullPage(true); void PrintDoc::print() { printer->setOutputFormat(QPrinter::NativeFormat); QPrintDialog printDialog(printer, this); if (printDialog.exec() == QDialog::Accepted) { view->print(printer); } }
so, rezult - > screen result A
After, I change orientation page -> result
Print to pdf works good.
As you can see, the web page does not enter the page in width. The question is, what should be done to ensure that the web page on the printed page is complete.
Thanks -
Hi...
is like QWebEngineView you need LAMBADA callback :-)
http://doc.qt.io/qt-5/qwebenginepage.html#toHtml
My solution at head from:
https://github.com/pehohlva/QOASIS/blob/master/test/dkernel/epubview.cppstartHtmlGrab && image.. put in a QTextEdit && print...
2 steep plus but is perfect...QT5 dont have QWebView ... after is QWebEngineView
Wy you not use QTextBrowser or QTextEdit for document? -
Try https://github.com/pehohlva/Tiny_Edit is inside a QTextBrowser i use to play RTF format & epub page.. Markdown ...
-
this project for printing does not use any special settings that I don't have.
Forgot to specify: I print my documents in Windows 7.
I tried to start printing through the QPrintPreviewDialog.QPrintPreviewDialog *preview = new QPrintPreviewDialog(printer, this); connect(preview, SIGNAL(paintRequested(QPrinter*)), view, SLOT(print(QPrinter*))); preview->exec();
In the preview window everything looks great, but the result of printing on paper is the same as in the screenshot. Moreover, I tried to print in OneNote and the result is just as bad.