How it works
Why do the vectors go beyond the frame?
QGIS writes SVG files with the SVG module of Qt. When it draws a map, QGIS clips the drawing to the frame of the map, but Qt does not write this clipping to the file: lines and polygons are written whole and reappear outside the frame in a drawing program. Raster layers are already cut as images and do not have this problem. This is what the warning of QGIS points out when exporting to SVG.
What the plugin does
During the export only:
for each checked map, it computes the clipping geometry (What cuts each map);
it creates a temporary in-memory copy of each displayed vector layer, whose features are cut by this geometry (features entirely outside are removed); the copy keeps the fields, the values and the whole style (symbology, labels, diagrams);
the map shows these copies instead of the original layers, with the same styles;
QGIS exports the SVG;
everything is put back: layers of the map, theme, locked styles, data-defined properties, and the copies are deleted.
The project and the layout are not changed, and no working file is written (except the GeoPackage if you ask for it).
- Reprojected layers
The clipping geometry is densified, then transformed to the CRS of each layer: a straight edge in the CRS of the map becomes a curve in another CRS (the frame of a WGS 84 map seen in UTM, for example), and the cut follows this curve. Layers in another CRS than the map are therefore cut exactly at the frame.
- Invalid geometries
The plugin tries to repair them to cut them; a feature that cannot be cut is left out of the export.
Limits
Only geometries are cut: a large point symbol or a very thick line right on the edge can still go beyond it by a few tenths of a millimetre.
Labels are placed on the cut geometries: a label at the centre of a cut polygon goes to the centre of the visible part.
A symbology that depends on the geometry (
$area,$length…) uses the cut geometries.