When I export SVG files from QGIS using the Print composer the stroke widths become a lot wider when importing into Adobe Illustrator. It seems like the stroke width in the SVG translates differently in Illustrator compared ti Inkscape.


A line in QGIS with the width 0.26 mm is shown as


in the SVG file. And when I open the file in Inkscape, it's still 0.26 mm wide but when I open it in Illustrator it shows the width of stroke as 3.07087 pt.

Does anyone have an idea why Illustrator doesn't "translate" 3.0787 to the right width?

And is it a way of fixing this? I guess I could search and replace in the SVG xml file but I'd rather not..

Does it have to do with the SVG length specs?

"If a unit is not provided, the length value represents a distance in the current user coordinate system."

Edit: I have now noticed that the mm width is 0.08466669263 times the value in the SVG XML file.

Edit 2: I have noticed now that if I alter or remove the "viewbox" bit in the SVG file, Inkscape also display the line width wrong, so it seems like Illustrator doesn't understand the viewbox and therefore translates the widths wrong!?


When exporting to SVG, QGIS leverages Qt's QSvgGenerator in QgsComposer::exportCompositionAsSVG. Note the SVG Export warning dialog:

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

With regards to opening the SVG directly in Illustrator, ensure that your base units in Illustrator for strokes are MM, not Points (the default), but do this prior to opening the SVG. You can also try setting the units to MM in the Document Setup if you are importing into an existing Illustrator document. These settings may not change the resultant import, though.

As you noted, Illustrator has trouble accepting the default MM units of the QGIS SVG export while Inkscape does a better job (Illustrator just doesn't seem to scale strokes at all). Therefore, you can try opening the SVG in Inkscape first, then exporting a PDF-formatted copy out. Opening the PDF copy in Illustrator should provide more accurate line width and font-rendering results than opening the SVG directly. I did not have good luck exporting to EPS from Inkscape, as it seemed to randomly rasterize parts of the output.

Likewise, you can also try exporting directly to PDF from QGIS and opening that in Illustrator. There will likely be differences in the result in Illustrator between the above SVG->Inkscape->PDF->Illustrator and PDF->Illustrator workflows. If you need more document structure, the former may be useful, though it destroys most of the SVG structure when the PDF format is introduced.

If you feel there is an issue that needs addressed here in the QGIS source code (if possible), please create a very detailed issue report, with lots of output sample comparisons, on the QGIS issue tracker. I could not find any existing issue ticket.

The best solution for SVG output in QGIS may be to create a custom exporter that is not tied to QSvgGenerator, or create a new QSvgGenerator subclass that pre-scales line widths for Illustrator-specific SVG output.

  • Thanks for the response. The thing is what makes me so puzzled is that when I chose 0.26 mm for a stroke weight, the SVG source says 3.0787. I don't understand what this 3.0787 is all about! But when I open in Inkscape it shows as 0.26 mm but in Illustrator as 3.0787 pt. I mean 3.0787 has nothint to do with the difference between mm and pt? It's like some kind of transformation that Illustrator misses? Or in the definition? (i'm repeating myself here).. – oskarlin Nov 27 '14 at 23:40
  • Oh and I tried to change the units to mm in Illustrator without any luck. And exporting to PDF doesn't do the trick since I want to keep layers and text intact. – oskarlin Nov 27 '14 at 23:41

I've been hunting for an answer to this for over a year. Best solution I've found is, once your SVG is open in AI, toggle off "scale strokes and effects," then scale your various object up or down so that the strokes look correct, relatively. Of course, now the objects are the wrong sizes. Now toggle "scale strokes and effects" back on, and scale your objects back to their original sizes.

It's still a pain, but its slightly better than re-adjusting every stroke individually. I'd be very interested in a proper solution.

  • See my "solution" below. That's how I do it. It's not beautiful but it works. – oskarlin Oct 8 '15 at 8:51

My own "solution" is this: Open the SVG file in a text editor. Look at the second line:

<svg width="999.998mm" version="1.2" xmlns="http://www.w3.org/2000/svg" height="699.939mm" viewBox="0 0 11811 8267" xmlns:xlink="http://www.w3.org/1999/xlink" baseProfile="tiny" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape">

Take the width value (in this case 999.998mm), and convert it to points. Do the same with the height value.

Then open the file in Illustrator. Select all. Go to Transform toolbar and copy the width value and translate it back to points. Paste this new translated value in the transform toolbar (make sure the Constraint with/height is toggled).

Now the size will be right together with strokes and widths. Oh and make sure you have scale strokes and effects active.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.