Can't convert print class from pyqt5 to pyqt6

In version 2.1.49 I had a add-on for printing decks on a home printer that worked great.
With the transition to 2.1.54 I encountered many errors that I could not solve.
My way of working was to create a page containing all the cards using QWebEngineView and then print it.
In the actual printing part, I based on the example given in the link below. My problem is that I could not in any way convert this example to pyqt6:

Any help will be appreciated!