Skip to content Skip to sidebar Skip to footer

Print Webpage From Qtwebkit.webview To Pdf Pyqt4

Hi what i'am trying to accomplish is that, i have a QWidget with a custom QtWebKit.QWebView which displays a particular website. I want to save that web page as a pdf using python

Solution 1:

If you want to save a web-page as pdf, use QPrinter:

    printer = QtGui.QPrinter()
    printer.setPageSize(QtGui.QPrinter.A4)
    printer.setColorMode(QtGui.QPrinter.Color)
    printer.setOutputFormat(QtGui.QPrinter.PdfFormat)
    printer.setOutputFileName('report.pdf')
    self.page().mainFrame().print_(printer)

EDIT:

If you're on Windows, you might be able to improve the quality with:

printer = QtGui.QPrinter(QtGui.QPrinter.HighResolution)

Post a Comment for "Print Webpage From Qtwebkit.webview To Pdf Pyqt4"