Le 20/10/12 15:59, Ajay Garg a écrit : > Hi all. > > I have been looking for ways to get things exported to PDF; I must say > that I am pleasantly surprised by the ease of exporting a > text-document to a PDF :) > > Googling also says that exporting an image to pdf is "easier" than > exporting a text-documnt in PyQt; unfortunately for me, I have not > been able to find the steps to do that :-\ > So, I will be grateful if I could be directed to a "Hello World" > program to do this. > > > My requirement is very simple :: > > * Read an image file (png/jpeg, etc). > * Export to PDF; simple. No editing of pixels, or any > other stuff. > > > > Looking forward to some pointers :) > > > > Regards, > Ajay > > > > _______________________________________________ > PyQt mailing list PyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt Minimalistic example:
#---------------------------------------------------------------------- image = QtGui.QImage("myImage.jpg") printer = QtGui.QPrinter() printer.setResolution(300) printer.setOutputFormat(QtGui.QPrinter.PdfFormat) printer.setOutputFileName("myImage.pdf") painter = QtGui.QPainter() painter.begin(printer) painter.drawImage(target, image, source) painter.end() #------------------------------------------------------------------------ where target & source are QtCore.QRectF(sheet) & QtCore.QRectF(image) A more complete example here: http://bazaar.launchpad.net/~vincent-vandevyvre/oqapy/serie-1.0/view/head:/oqapy-1.0/printing.py -- Vincent V.V. Oqapy <https://launchpad.net/oqapy> . Qarte <https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager> _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt