1

So, I'm trying to print a QWebEngineView entirely, but give a Preview Dialog, such as QPrintPreviewDialog would be sufficient.

First try was something along these lines:

self.loader = QWebEngineView()
[...]
dialog = QPrintPreviewDialog()
dialog.paintRequested.connect(self.loader.page().print)
dialog.show()

self.loader is also used as the actual view rendered to screen. In this setup I get one page sent to the preview and that is the current view in the window. But not the entire document, which is what I want.

I can simply call self.loader.page().print(), which works (prints everything) but gives me no preview option.

I then tried to be smart by using

self.loader.page().runJavaScript("window.print();")

But that doesn't appear to trigger any reaction whatsoever.

So, how do I get an entire WebView printed with a preview dialog beforehand?

In this case PyQt5/PySide2 would be preferred, but I can understand a regular Qt Solution just fine too.

Berserker
  • 1,112
  • 10
  • 26
  • It appears it's still not implemented in Qt: https://bugreports.qt.io/browse/QTBUG-57982. One workaround suggested within that ticket's comments is printing to PDF and then showing that PDF (e.g. with pdf.js) as a preview. – Dmitry Apr 26 '18 at 08:09
  • Well, that is good to know. "Only" wasted a workday on this >.> Since we intend to ship in June, which is also when 5.12 is scheduled maybe we can sneak in the update before final test phase. – Berserker Apr 26 '18 at 08:29

0 Answers0