from PySide2.QtWidgets import QApplication, QMainWindow, QPushButton
from PySide2.QtWebEngineWidgets import QWebEnginePage
from PySide2.QtCore import QUrl
import sys
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
button = QPushButton("Print!")
button.clicked.connect(self.the_button_was_clicked)
# Set the central widget of the Window.
self.setCentralWidget(button)
def the_button_was_clicked(self):
# qurl = QUrl()
url = QUrl.fromUserInput("file:///home/dev/Images/source.svg")
file = "output.pdf"
qwp = QWebEnginePage()
qwp.load(url)
qwp.printToPdf(file)
Can someone help me understand why the code above does not work?