Bug report #159

SVG export doesn't crop layers to page size

Added by yajcolin-nospam-free-fr - over 14 years ago. Updated almost 3 years ago.

Status:Closed
Priority:Low
Assignee:-
Category:Map Composer/Printing
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

Description

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.

Yves

bug_qgis_svg.jpg - description of the problem when exporting in svg (219 KB) yjacoli-nospam-free-fr -, 2006-06-25 03:02 AM

SVG_export_options_123.png (27.2 KB) Alessandro Sarretta, 2016-11-28 01:36 PM

History

#1 Updated by Gavin Macaulay - over 14 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 over 13 years ago

Changed to minor under the following scheme:
  • 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 - over 12 years ago

An update on this bug:

The svg implementation in Qt (v4.4.0 when I last checked) only supports the static features of SVG 1.2 Tiny. This doesn't include clipping of shapes, which is the subject of this ticket. There is a Qt bug filed for this (204966), but no indication of when it will be resolved.

#4 Updated by Brendon Wolff-Piggott - about 12 years ago

Checked this in QGIS 1.0.0 Preview II. Confirmed this problem still exists.

#5 Updated by Paolo Cavallini over 11 years ago

The bus seems still open upstream. Could someone check with Qt 4.5? The QGIS version should have little relevance. Thanks.

#6 Updated by Giovanni Manghi over 11 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?

#7 Updated by Steven Bell - over 11 years ago

Personally, I would suggest leaving it open. Although the problem stems from a Qt deficiency, it's possible to work around it with code in QGIS. I vaguely recall that there may have been code to do this which was removed in the port to Qt 4.

#8 Updated by gjm - over 11 years ago

I'd also suggest leaving it open. It falls under the category of 'not our fault', but I think it's useful to have it flagged here, if only to remind us of the problem (and someone might fix it if it remains open in trac).

#9 Updated by Giovanni Manghi over 11 years ago

Ok, for me, pushing milestone to 1.2.0

#10 Updated by Giovanni Manghi almost 9 years ago

  • Target version changed from Version 1.7.0 to Version 1.7.4

#11 Updated by Paolo Cavallini over 8 years ago

  • Affected QGIS version set to master
  • Target version changed from Version 1.7.4 to Version 1.8.0
  • Crashes QGIS or corrupts data set to No

#12 Updated by Paolo Cavallini about 8 years ago

  • Target version changed from Version 1.8.0 to Version 2.0.0

#13 Updated by Evan Derickson over 6 years ago

Since the upstream bug (now located here) is marked as Won't Fix, it would seem that a workaround is the only remaining option.

#14 Updated by Jürgen Fischer over 6 years ago

  • Category changed from 33 to Map Composer/Printing

#15 Updated by Nyall Dawson over 6 years ago

  • Assignee deleted (Gavin Macaulay -)
  • Target version deleted (Version 2.0.0)
  • Resolution set to up/downstream
  • Pull Request or Patch supplied set to No

#16 Updated by Evan Derickson over 6 years ago

Since the bug is marked as Won't Fix upstream, I disagree with the resolution being marked as upstream. This will need to be fixed in QGis because it's outside the scope of Qt.

#18 Updated by Giovanni Manghi over 6 years ago

  • Operating System deleted (All)
  • Status info deleted (0)

#19 Updated by Evan Derickson over 6 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:

Deferred:

Fixing this bug would require implementing features of the SVG 1.1 Clip Module [1], 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.

[1] http://www.w3.org/TR/SVG11/masking.html#clip-mod

#20 Updated by Alessandro Sarretta about 4 years ago

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.

#21 Updated by Giovanni Manghi over 3 years ago

  • Easy fix? set to No
  • Regression? set to No

#22 Updated by Alessandro Sarretta almost 3 years ago

Tested with the 3.1.0-Master f35745f
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):

#23 Updated by Giovanni Manghi almost 3 years ago

  • Description updated (diff)
  • Status changed from Open to Closed

Closing as it is an upstream bug.

Also available in: Atom PDF