Priority: P3: Somewhat important
Affects Version/s: 5.15.0
Fix Version/s: None
Component/s: GUI: Printing
I want to export the contents of a widget to either PDF or SVG and add a title.
For exporting to SVG, I use QSvgRenderer, and for PDF, I consider QPrinter and QPdfWriter.
For SVG everything works fine. But when using QPrinter as the QPaintDevice, the widget text gets rasterized even though the added title gets correctly exported as scalable text! I don't understand why this would happen.
When using QPdfWriter as a possible workaround, the added title text is much larger than rendered widget text, which makes no sense and is completely inconsistent to all other behaviors. I'm lost here. Should I open a different issue for the QPdfWriter problem?
A minimal example is attached. QPrinter can be swapped for QPdfWriter using the defined macros. I also tried to render directly to a paint device but it doesn't seem to matter and also does not seem to work when I want to add a title. Exporting to svg or pdf gets triggered when pressing the s key.
SVG as rendered using a QPainter to QSvgRenderer (the screenshot is still from an old version using blue instead of magenta):
PDF as rendered using a QPainter to QPrinter (the text in the center is rasterized but not the title):
PDF as rendered using QPainter to QPdfWriter (the centered text is much smaller than the title text but nor rasterized. Also there is a white line at the bottom hinting to some weird rounding error!):
^As for the size difference. My guess is that the default DPI is for some reason a different one in printer vs. pdfwriter?^