Bug report #3224

SVG export scales page content (but not page size) to 333.3% of what it should be.

Added by Alister Hood almost 10 years ago. Updated almost 10 years ago.

Status:Closed
Priority:Low
Assignee:Marco Hugentobler
Category:-
Affected QGIS version: Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied: Resolution:fixed
Crashes QGIS or corrupts data: Copied to github as #:13284

Description

- Create a composer layout and add a map to it.
- Export as SVG
- Open the SVG in a browser - you will only see the top corner of the map.
- Open the SVG in inkscape - you will see that the page contents (map, north point etc) are all scaled to 333.3% of the size that they should be, but the page is the correct size.

N.B. I'm using the Windows QGIS from the osgeo installer - I don't know if the bug is also present on other platforms.

mrt_300.svg - Minimum reproducible test - 10mmx10mm rectangle on landscape A4 at 300dpi (4.32 KB) JD -, 2010-12-14 05:16 AM

mrt_600.svg - Minimum reproducible test - 10mmx10mm rectangle on landscape A4 at 600dpi (4.29 KB) JD -, 2010-12-14 05:16 AM

History

#1 Updated by Giovanni Manghi almost 10 years ago

If I'm not wrong, the problems with svg export in the print composer are well know and are not about QGIS. It should be a QT bug. If I remember well a ticket like this was already filed, please have a look, also among already closed ones.

#2 Updated by Alister Hood almost 10 years ago

Several other bugs have been filed about svg export, but not this one.

#3 Updated by Alister Hood almost 10 years ago

Oh, I see.
It isn't always 333%.

The SVG content is being scaled according to the selected "Quality".
It is the correct size if this is set to 90 dpi. (I previously had it set to 300 dpi:
300/90 = 3.33)

#4 Updated by Marco Hugentobler almost 10 years ago

If you open it with inkscape, you see that the exported size is in pixels and should be correct (of course the pixel size depends on the dpi).

Is there a setting in inkscape to set the dpi of the document? It seems to draw the paper size based on screen dpi (usually around 90). But this is not suitable for printing.

#5 Updated by Alister Hood almost 10 years ago

I'm pretty sure Inkscape is not the problem. Try this:
- set the Quality to 300dpi
- export as svg
- open the svg in a web browser
You will only see the top left corner of the svg.

#6 Updated by JD - almost 10 years ago

I can confirm this bug on QGIS 1.5 and Inkscape 0.47 on Kubuntu 10.04.

It is definitely the SVG export from Quantum, because looking inside a simple SVG, every <g> node has the attribute: transform="matrix(11.8081,0,0,11.8081,0,0)" if it exported at a quality of 300 DPI, and transform="matrix(23.619,0,0,23.619,0,0)" for 600 DPI

#7 Updated by JD - almost 10 years ago

Playing around with a quick Qt 4.6.0 test app, it seems that the scale issue can be fixed by either setting the source and target areas to be the same, or by setting the viewBox explicitly. The former seems to not scale text properly, and the latter can be achieved by adding:

  generator.setSize( QSize( width, height ) );
  generator.setViewBox( QRect( 0, 0, width, height ) ); //<-- Add this line
  generator.setResolution( mComposition->printResolution() ); //because the rendering is done in mm, convert the dpi

#8 Updated by Marco Hugentobler almost 10 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

Applied in 3a48287f (SVN r14911). Thanks!

Also available in: Atom PDF