If you render a QGraphicsScene containing a QGraphicsSvgItem to a QPrinter, the generated PostScript is garbage if the SVG contains a <rect> element.
- Run the program below as-is, printing to a Postscript printer. (I am using the "Print to file" option in Ubuntu so as not to waste paper, but the results are the same if you actually print to a physical printer.) Notice:
- It finishes quickly
- If you open the PS document in an image viewer, the full image is printed
- If you open the PS document in a text editor, it is relatively clean (by postscript standards...)
- Next, uncomment the line in the SVG containing the <rect> element (marked with comment "problem" at the end of the line) and run it again. Notice:
- It takes a long, long time to generate the output.
- If you open the PS document in an image viewer, the image is clipped at the size of the rectangle.
- If you open the PS document in a text editor, it contains a huge block of garbage commands.
It is fine going to a QGraphicsView. I have reproduced this problem on Ubuntu 10.10 and Windows 7 (physical print and XPS print), although on one Windows 7 machine I was not able to reproduce it. It also works fine if printing to PDF; just postscript is generating garbage.