Copy link to clipboard
Copied
I have some custom SVGs that use <!ENTITY> declarations for parameterization / customization. When I edit and then save those SVGs in Illustrator, my <!ENTITY> declarations disappear. Is there any way to edit the graphical content of the SVG in Illustrator and save while preserving <!ENTITY> declarations?
Copy link to clipboard
Copied
Illustrator interprets SVGs when importing them.
So this happens when opening the files and you cannot prevent it.
You might ask for a feature: https://illustrator.uservoice.com
Copy link to clipboard
Copied
Hi @Marc36676225fmed, Just to add to Monika's correct answer—Illustrator is not an SVG editor.
Illustrator imports svg files—but really only the elements that it can convert to native Illustrator objects—other elements will be lost. And then you have an Illustrator document, not an SVG document. Thereafter saving as SVG is actually the same process in reverse—converting those elements from the native Illustrator document into SVG, and discarding any native Illustrator elements that can't be translated into SVG elements. But in no way is this to be considered opening and saving an SVG document—it involves two destructive conversions.
You tagged "scripting", and I think it should be possible to script a workflow that would do what you want. It could work something like this:
1. Open (ie. convert to Illustrator DOM) your SVG file that has <!ENTITY> elements—let's call it the "original" svg. Do not save it over the original svg file.
2. Run the hypothetical "Update SVG" script.
3. Script asks you to select a SVG file—you select the original svg file.
4. Script exports current document as SVG—let's call this the "temporary" svg.
5. Script reads XML of both original and temporary SVG files.
6. Script matches elements between them, and for each match, update either the original, or a new svg file.
This would leave the elements of the original SVG intact, except for the elements that you specifically asked to be updated, which could be, for example, a group element inside your <!ENTITY> element. There would be limitations, such as not adjusting the viewBox if the artwork size changed, but script could update the viewBox with the temporary SVG's viewBox.
It wouldn't be the simplest script to write. But for the sake of discussion, how does that sound?
- Mark