Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How do you print QWebEngineView content in PyQt6?
Qt 6.11 is out! See what's new in the release blog

How do you print QWebEngineView content in PyQt6?

Scheduled Pinned Locked Moved Solved Qt for Python
4 Posts 2 Posters 251 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rida_zouga
    wrote last edited by
    #1

    Currently developing an app for managing stores, and the app makes an invoice or receipt of items sold for example, so ideally made that invoice with the help of Jinja template (populated with those items fetched from db), then because of limitations of QTextDocument at rendering html (which I managed to overcome at first in my case, but then the font size of document keeps changing from pc to pc with same code, and couldn't handle that issue or solve it), I decided to go for QWebEngineView and made it work, but now when it comes to printing it, I simply couldn't find ANY POSSIBLE way to do so, whether by .printToPdf then create a QPdfDocument, or even go beyound that with QPdfView, since unfortunately the print() method that used to be on QWebEngineView.page() is depracated in the recent versions of qt and internet is only full of that solution (even the qt example shows only that way here), so how do you handle printing the content of QWebEngineView in these recent versions or do you recommend another entire approach for this and THANK YOU!

    JonBJ 1 Reply Last reply
    0
    • R rida_zouga

      Currently developing an app for managing stores, and the app makes an invoice or receipt of items sold for example, so ideally made that invoice with the help of Jinja template (populated with those items fetched from db), then because of limitations of QTextDocument at rendering html (which I managed to overcome at first in my case, but then the font size of document keeps changing from pc to pc with same code, and couldn't handle that issue or solve it), I decided to go for QWebEngineView and made it work, but now when it comes to printing it, I simply couldn't find ANY POSSIBLE way to do so, whether by .printToPdf then create a QPdfDocument, or even go beyound that with QPdfView, since unfortunately the print() method that used to be on QWebEngineView.page() is depracated in the recent versions of qt and internet is only full of that solution (even the qt example shows only that way here), so how do you handle printing the content of QWebEngineView in these recent versions or do you recommend another entire approach for this and THANK YOU!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote last edited by
      #2

      @rida_zouga
      Not my area, but are you aware that QWebEngineView, rather than QWebEnginePage, still has void QWebEngineView::print(QPrinter *printer)? All printing seems to go via one of the printToPdf() methods.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rida_zouga
        wrote last edited by
        #3

        Oh yes sorry my bad, the print method eventually still exists for the QWebEngineView in the recent versions too, again sorry and thank you so much for your help.

        JonBJ 1 Reply Last reply
        0
        • R rida_zouga has marked this topic as solved
        • R rida_zouga

          Oh yes sorry my bad, the print method eventually still exists for the QWebEngineView in the recent versions too, again sorry and thank you so much for your help.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote last edited by
          #4

          @rida_zouga
          Sorry, yes, I forgot you said Python. I just search/post links from C++ reference pages.

          https://doc.qt.io/qt-6/qtwebengine-changes-qt6.html#qwebenginepage

          QWebEnginePage

          Has been moved to Core, and API that worked on QWebEngineView or QPrinter has been moved, and can now be accessed only from QWebEngineView. See Changed API.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved