Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.10.1
-
None
-
Windows 7 x64 Ultimate.
Visual Studio 2015 Enterprise Update 3.
Prebuild Qt 5.10.0 from qt ftp server.
-
-
I1e6242627821d57f877b587c1d760fac16c97ae2
Description
I need to make shadow copy of printed document as pdf file. I want to do this in print's resultCallback.
But i get an error:
Cannot print to PDF while at the same time printing on printer Microsoft XPS Document Writer
Example:
#include <QApplication> #include <QCoreApplication> #include <QWebEngineView> #include <QWebEngineSettings> #include <QPrinter> #include <QPrintDialog> int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication a(argc, argv); QPrinter printer; QWebEngineView* viewer = new QWebEngineView(); viewer->settings()->setAttribute(QWebEngineSettings::PrintElementBackgrounds, true); QObject::connect(viewer->page(), &QWebEnginePage::loadFinished, [&](bool ok) { QPrintDialog printDialog(&printer); if (printDialog.exec() == QDialog::Accepted) { printer.setPaperSize(QPrinter::A4); printer.setPageOrientation(QPageLayout::Landscape); printer.setPageMargins(0, 0, 0, 0, QPrinter::Millimeter); printer.setFullPage(true); //print on printer viewer->page()->print(&printer, [&](bool result) { //print to pdf viewer->page()->printToPdf(QString("tmp.pdf")); }); } }); viewer->load(QUrl("http://google.com")); viewer->show(); int result = a.exec(); delete viewer; return result; }
Attachments
For Gerrit Dashboard: QTBUG-69222 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
233776,3 | Unset currentPrinter before triggering the callback of printing operation | dev | qt/qtwebengine | Status: MERGED | +2 | 0 |