Illustrator SVG can't be opened by Illustrator after inkscape touches them

Bug #179679 reported by Martin Andersen on 2008-01-01
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
High
Martin Owens

Bug Description

If you resave an illustrator SVG in Inkscape, it means it can't be opened in Illustrator again.
Inkscape 0.46dev Dec.29 build, Windows Vista

[Saving an Illustrator file with layers as SVG and opening it in Inkscape, not only doesn't Inkscape recognise the Layers (which simply use <g id="Layername"> , where Inkscape use proprietary Inkscape tags), it opens up as having no layer at all, not even a Default one. It is problematic recreating the Layers, as layers will automatically go above all the non-layered objects.
When importing Illustrator SVGs, Inkscape should be able to recognise Illustrator's layers. ] [This part of the bug is a dupe of bug 179680 - Tom Davidson]

Related branches

John Cliff (johncliff) wrote :

It cant be opened in illustrator again? Does it give an error or anything? That actually sounds like a bigger bug than the layers thing. As that is just we dont support their fudge for layers, whereas the not opening breaks the "we write standard svg that should open anywhere" philosophy. May just be AI has rubbish SVG import and cant cope with non svg namespace tags or something in which case its not our issue, but thats something we need to resolve.

Changed in inkscape:
importance: Undecided → High
status: New → Confirmed
Martin Andersen (msandersen) wrote :

I don't normally use SVGs in Illustrator (they seem to use their own nonstandard filters to go with their browser plugin), but I was wondering about how the layers were enoded, though I'm not a coder.
I just did another test using the Inkscape logo, opening it in illustrator CS2, resaving a copy, and opening it in Inkscape again, and resaving a 3rd copy, and comparing the 3 files in a text editor.
the final 3rd file, saved from Inkscape, silently fails to open in Illustrator.
The 3 files are radically different. I will attach them. Illustrator is doing something funky, attaching a huge CDATA field
<i:pgf id="adobe_illustrator_pgf">
 <![CDATA[
Inkscape rewrites the file, the header looks very different, and it removes the CDATA tag:
<i:pgf
   id="adobe_illustrator_pgf">
each followed by a large block of encoded data. I'm sure Inkscape shouldn't remove the CDATA tag, whatever that junk is. It is probably why Illustrator fails to reopen it.

As for layers, all I ask is that the import/open recognise it as an illustrator file and use its Layers format. Considering how radically different the formats are, that should be easy.

Incidentally, the inkscape formatting is harder to read than Illustrator's. I expect XML formatting conventions are similar to HTML. not that the SVG is meant to be read by people.

Compare the following 2 attachments to share/clipart/inkscape.logo.svg

Martin Andersen (msandersen) wrote :
Martin Andersen (msandersen) wrote :

The original logo file was only 2kb, the illustratore SVG is blown out to 24kb becaus eof the CDATA, and the resaved Inkscape file is slightly larger again.

Martin Andersen (msandersen) wrote :

I just confirmed the removed CDATA tag was the problem. I manually removed the large block of data in the <i:pgf id="adobe_illustrator_pgf"> tag from the 3rd file (it went down from 25kb to 5kb), and it opened fine in illustrator.
Maybe it's a preview icon or something for the Mac, which Windows can't make use of anyway. I'd say simply remove the whole block when encountered, it doesn't seem to affect the file.
Obviously the problem is only encountered when an Illustrator SVG is opened and resaved in Inkscape.

Martin Andersen (msandersen) wrote :

This is getting off-topic, but I did some research and found out what the CDATA is:
http://support.adobe.com/devsup/devsup.nsf/docs/52613.htm
Quote:
"If you save an SVG file from Illustrator with the "Preserve Illustrator Editing Capabilities" checkbox selected, Illustrator writes out what amounts to an embedded native .ai file in the SVG. When Illustrator reads the SVG file back in, it sees this embedded information and reads it instead of the SVG content.

You can see the embedded editing information by opening the SVG file in a text editor and scrolling to the end of the file while looking for "<i:pgf". If you delete the entire <i:pgf ...> node, Illustrator will read the SVG data and you'll see the Adobe Server changes. (The ... represents the enclosed .ai info.) This also makes the file smaller making it process faster in Adobe Server."

Hence you break AI compatibility by leaving the <i:pgf tag but removing the CDATA tag around the binary data.

Compare the attached file with the 1st file attachment above (2 inkscape logo-illustrator test.svg). The only difference is I unticked the default option to preserve editing capability.

Sorry, I haven't checked if there's a bug report relating to the <i:pgf and CDATA tag, or Illustrator compatibility. I will open one if you wish.

Tom Davidson (tjd-mit) wrote :

Since you also filed bug 179680 to report the specific issue that Illustrator's layers are not recognized, I've renamed this bug to reflect the problem of Illustrator SVG files not being re-openable by Illustrator after being saved by Inkscape.

description: updated
Martin Andersen (msandersen) wrote :

From my analysis above, the bug only occurs when AI's default "Preserve Illustrator Editing Capabilities" option is left checked. As such, I'd say most AI SVGs would be affected, as it sounds like a good idea to retain editability, and like most, if you're not sure, you leave it at its defaults. An AI SVG saved without this option will not contain the encoded binary .ai file in the CDATA, which is what it actually opens when present, so all's well. I guess there's nothing else I can add.
Thanks for Inkscape, it's important as the only dedicated SVG drawing program, and from this I've learnt how Illustrator, and probably others, can fill them with nonstandard proprietary filler.

Jerry W. Segers, Jr. (segers-j) wrote :

I'd like to add my two cents to this conversation. As Martin Andersen pointed out Illustrator reads the binary data if present. To amplify my point - Illustrator ignores the svg file as anything but a weird wrapper for an illustrator file if that block exists. If any changes are made in Inkscape, they will be unavailable in Illustrator unless the block is deleted.

I propose a warning dialog that defaults to deleting the block with the wording Warning, this file contains an embedded illustrator element that will prevent your changes being seen in Adobe products. To make your changes visible in Adobe products you must delete this element (keep) (delete)[]always do this

Where () represents a button and [] represents a checkbox

Thanks for listening.

Does this situation occurs when you save your SVG file as "Optimized SVG" or as "Plain SVG"?

I'm saying this because one time I had to follow a tutorial on SVG animation using CSS techniques and only one of the SVG options Inkscape saves files as worked. Just trying to help here as well.

Martin Owens (doctormo) wrote :

I've added a prune in r15141 which will remove the i:pgf tag when found, the method can later be expanded to strip out any other problematic tags. The new prune works for both inkscape and plain svg files.

I confirmed that trunk inkscape does not remove CDATA tags any more, so that part of the bug is already fixed.

I won't backport this addition to 0.92 as I believe it won't be that useful now the cdata issue is fixed. But at least we can clear up the "I changed the file and Illustrator doesn't show the changes" bug.

Changed in inkscape:
assignee: nobody → Martin Owens (doctormo)
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers