PDA

View Full Version : printing widget(s) to postscript or PDF using vector graphics and not pixmap backing



jcbikeski
23rd July 2011, 00:58
Trying for the first time to print a custom widget of mine I created a QPrinter set to do postscript or PDF output and called the top widget's render() method. This did draw to the output file but as a pixmap (so not scalable). Reading the Qt code I see code suggesting this behavior may be an option and there may be a way to pass the QPrinter PaintDevice directly to my widget's paint routines so when I call things like mypainter->drawLine it results in a scalable vector rather pixels.

So I'm wondering if others have done such saving of real scalable vector graphics from custom widgets and what settings they may have needed to make this work

thanks for any help!

John

Cruz
23rd July 2011, 11:45
I have used the QSVGGenerator (http://doc.qt.nokia.com/4.6/qsvggenerator.html#details) before to create vector graphics and it worked really nicely.

jcbikeski
24th July 2011, 23:58
It looks easy to output one widget to QSVGGenerator but what about a multiple widgets contained in a window? I was hoping I could just set a painter to something like postscript or SVG (not as ideal since not as many document applications support this) and have Qt draw the compound widget using that painter. Instead (by default at least) the render method of QWidget (which handles compound widgets) seems to paint to a pixmap then copy that to the document as an imbedded pixel oriented image (so not scalable cleanly).