Preventing removal of SVG attributes when used on the command line
by Pilar Sopena
I started to use recently Inkscape through the command line to convert text
> inkscape cool_drawing_with_text_and_colours.svg --export-text-to-path
This conversion is part of a process for converting an SVG into a PDF/X
using different technologies.
The output PDF/X needs to have colour information. The colour information
can be CMYK or spot colours. The PDF/X library expects certain attributes
on the SVG to reflect the exactly same colours in the result PDF/X.
For example, if we want to include CMYK information, the PDF/X library
> <rect fill="#FF0000 device-cmyk(1,1,0,0)"/>
We found that Inkscape removes attributes, so we use icc-color(cmyk, 1, 1,
0, 0) rather than device-cmyk(1,1,0,0) and then after the Inkscape step we
translate each icc-color(cmyk, ...) it to device-cmyk(...) attribute.
For using spot colours, the workaround it's a bit more creative. The PDF/X
library expects the following SVG
> <rect fill="#FF0000 icc-named-color(profile, 'Cool Red (102))"/>
The attribute icc-named-color(...) gets stripped away, so we found a
workaround using again icc-color(...) too and we do the translations back
after. To ensure the values are kept after using Inkscape we use aliases
and then we translate the aliases back. With no aliases not every named
color will stay on the result SVG after Inkscape. For example:
<rect fill="#FF0000 icc-color(spot-1)"/>
And after we will translate icc-color(spot-1) to icc-named-color(profile,
'Cool Red (102))
I didn't find any other attribute except *icc-color* to work on this
workaround, is there a list of svg attributes that are accepted by Inkscape
Is there a way of preventing any of these attributes to be removed, any
options on the command line that I've missed? It removes several attributes
not only the ones mentioned above.
I attached an example of the SVG that I'm trying to process with Inkscape,
in case that helps.
Thank you very much, any help or suggestions will be welcome!
*Pilar Sopena Suils*
Senior Backend Engineer
Office: +44(0)20 39716787 <%2B44%280%2920%203701%207639>
Unmade, 28A Easton Street, London, WC1X 0DS
Registered UK business no. 08498078
2 years, 10 months