Search code examples
pythonqtpdf-generationpyqt4

Creating a PDF from a QT application


I'm working on an app that will display an image and some text. But I want to export the whole QT interface as a PDF (By pressing on a button on the UI itself). All the text and all the images just as it appears on the UI.

Now if that isn't possible, maybe I can some how automatically create a jpg, save it and then somehow, using reportlab, to convert the jpg to a PDF.

I have no idea where to start. Can any one please give me an example or even just a hint.


Solution

  • You can use QPixmap.grabWidget to capture you main window widget and QPrinter to produce a pdf file. A QPainter is needed to draw the pixmap to the printer.