Bug report #159
SVG export doesn't crop layers to page size
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||up/downstream|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||10218|
if I export a map in svg and if I zoomed in this map, svg export wil export all the map, not only the extended zoom.
E.g. : I get a map of my country. I zoom in a county (to get only the north of my country for instance). The svg export get all the map, not just the county ! It can be good to "crop" all the rest of the map unnecessary.
#1 Updated by Gavin Macaulay - almost 15 years ago
I can explain why this is happening, but don't have a solution for 0.8.
If an item is visible on the map, even just a small part of it, qgis draws the whole item. The svg writing part of Qt does the same, and uses a clip rectangle in svg to trim away the unwanted bits. From your example it looks like the large red shape is a single polygon, and a small part of that is included in the visible area.
It could be possible to use the existing trimming ability of qgis (originally there to work-around a problem X11 displays) to trim the svg output, but this would be a significant change that we wouldn't like to put in 0.8 - perhaps 0.9, hence I'll move this bug's milestone to 0.9
#2 Updated by Tim Sutton about 14 years ago
- blocker - bugs that should block the release. Since we are going to release pretty much 'come what may' I would like no bugs
- allocated to this category without consultation with me and / or PSC
- critical - bugs that cause the application to crash or corrupt data
- major - application features that do not function at all
- minor - features that function but imerfectly e.g. labels placing incorrectly
- trivial - gui useability issues or small issues with the documentation, install notes etc.
#3 Updated by gjm - almost 13 years ago
#6 Updated by Giovanni Manghi about 12 years ago
Since version 1.1 qgis shows this message:
"The SVG export function in Qgis has several problems due to bugs and deficiencies in the Qt4 svg code. In particular, there are problems with layers not being clipped to the map bounding box. If you require a vector-based output file from Qgis it is suggested that you try printing to PostScript if the SVG output is not satisfactory."
Not a qgis issue. Closing?
#17 Updated by Nyall Dawson almost 7 years ago
This bug is still active: https://bugreports.qt-project.org/browse/QTBUG-23200
#19 Updated by Evan Derickson almost 7 years ago
The issue linked in comment 17 appears to be a duplicate of the issue linked in comment 13. The latter is marked as Out of Scope, and the text of the former supports this.
From the bug report:
Fixing this bug would require implementing features of the SVG 1.1 Clip Module , and we currently only support SVG 1.2 Tiny.
A work-around is to use the viewBox property of the QSvgGenerator to set a clip manually (new in 4.5). While this will not clip individual paint operations it will clip the resulting document to a given rectangle.
#20 Updated by Alessandro Sarretta over 4 years ago
- File SVG_export_options_123.png added
Testing this issue with QGIS version 2.18.0, code revision d8f9d2e, it seems that some workaround has been implemented, because when exporting the svg, an "SVG export options" window appears (see figure).
Anyway, the exported svg is still not perfect, because its extension exceed the extension of the features included in the layout.
#22 Updated by Alessandro Sarretta over 3 years ago
The output has the same behaviour as described in comment 20.
As an addition, below I copied the new active links to the two Qt bugs referred in comments 13 and 17 (old URLs are no more active):