Bug report #20309

QGIS 3.2 .SVG exports no longer compatible with Adobe Illustrator

Added by M CUSHEN over 5 years ago. Updated about 5 years ago.

Status:Feedback
Priority:Normal
Assignee:-
Category:Map Composer/Printing
Affected QGIS version:3.2.3 Regression?:No
Operating System:Window 7 64 bit Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:28130

Description

In QGIS 3.2.3 svg map exports are no longer compatible with Adobe Illustrator.

When svg exports from 3.2.3 are opened in Adobe Illustrator, users get the following message:
'This SVG is invalid. Validate it before opening.'

I have created a python script that generates an .svg export from a QGIS template qps file.
These exports use predefined map composer templates and retains QGIS styles (thanks to pixel units), layers, and layer names.
The script worked fine in Qgis 3.0.0 however the exports from 3.2.3 are no longer compatible with Adobe Illustrator.

looking at the change log for 3.2 it seems that the type of svg exported is different.
I suspect this is the source of the issue.
'Feature: Project metadata embedded in layout exports'
https://www.qgis.org/en/site/forusers/visualchangelog32/index.html#id50

Tested with:
  • Adobe Illustrator CS6 (64 bit), and
  • Adobe Illustrator CC 2018
On:
  • Window 7 64 bit
  • QGIS 3.2.3

deselect export rdf metadata.png (49.6 KB) Jesse Finley, 2019-02-27 06:27 AM

History

#1 Updated by Nyall Dawson over 5 years ago

  • Status changed from Open to Feedback

Can you identify what component of the svg is invalid?

#2 Updated by M CUSHEN over 5 years ago

Nyall Dawson wrote:

Can you identify what component of the svg is invalid?

It seems to be related to the metadata section.
If that block is removed the svg opens no problem in AI.
Here is the problem block:
<metadata id="qgismetadata">
<rdf:RDF>
<cc:Work>
<dc:format>image/svg+xml</dc:format>
<dc:title></dc:title>
<dc:date></dc:date>
<dc:identifier></dc:identifier>
<dc:description></dc:description>
<dc:creator>
<cc:Agent>
<dc:title></dc:title>
</cc:Agent>
</dc:creator>
<dc:publisher>
<cc:Agent>
<dc:title>QGIS 3.2.3-Bonn</dc:title>
</cc:Agent>
</dc:publisher>
<dc:subject>
<rdf:Bag/>
</dc:subject>
</cc:Work>
</rdf:RDF>
</metadata>

Replacing the metadata with the following does allows the svg to open successfully (I found this sample online):

<metadata>

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c142 79.160924, 2017/07/13-01:06:39">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""/>
</rdf:RDF>
</x:xmpmeta>

</metadata>

#3 Updated by Giovanni Manghi over 5 years ago

  • Assignee deleted (M CUSHEN)
  • Status changed from Feedback to Open

#4 Updated by Nyall Dawson over 5 years ago

  • Status changed from Open to Feedback

Can you try adding the xmlns attributes described at https://www.w3.org/TR/SVG11/metadata.html and see if this helps?

#5 Updated by M CUSHEN over 5 years ago

Adding the xmlns attributes, as linked, to the existing metadata still resulted in an invalid svg.

However changing the existing metadata to be in the following format, shown in the link, fixed the issue:
<metadata>
<rdf:RDF
xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs = "http://www.w3.org/2000/01/rdf-schema#"
xmlns:dc = "http://purl.org/dc/elements/1.1/" >
<rdf:Description about="http://example.org/myfoo"
dc:title="Sample QGIS Output"
dc:description="Sample Description"
dc:publisher="QGIS 3.2.3-Bonn"
dc:date="2000-04-11"
dc:format="image/svg+xml"
dc:language="en" >
</rdf:Description>
</rdf:RDF>
</metadata>

#6 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Feedback to Open

#7 Updated by Jesse Finley about 5 years ago

I was having a similar problem with SVG file in Illustrator CC giving the error message 'This SVG is invalid. Validate it before opening.'

The solution for me was simple:

Print > Layout > Export SVG 
Enter file name and save location > Save
*On the SVG Export Options - deselect "Export RDF metadata"

The SVG loaded fine in Illustrator, but make sure to reduce the line stroke (it is 1px by default)

#8 Updated by Giovanni Manghi about 5 years ago

  • Status changed from Open to Feedback

Jesse Finley wrote:

I was having a similar problem with SVG file in Illustrator CC giving the error message 'This SVG is invalid. Validate it before opening.'

The solution for me was simple:

worth a note in the documentation?

Also available in: Atom PDF