Preventing removal of SVG attributes when using the command line
We use Inkscape command line to convert the text into paths on SVG files. And we notice that the majority of the attributes being present on the the input SVG end up being stripped away.
We run Inkscape as follows:
inkscape cool_drawing_with_text_and_colours.svg --export-text-to-path --export-plain-svg
We need to preserve the colour information on the SVG and then the library we use to convert SVG into PDF/X will identify and reflect correctly the information on the result PDF/X.
The colour information can be CMYK or spot colours.
If we want to include CMYK information, the PDF/X library expects an SVG with attributes like this one:
<svg>
<rect fill="#FF0000 device-cmyk(1,1,0,0)"/>
</svg>
And if we want to include spot colour information, the SVG expected will look like this one:
<svg>
<rect fill="#FF0000 icc-named-color(profile, 'Cool Red (102))"/>
</svg>
However, Inkscape removes those attributes, along others like id
, data-xxx
, etc. We found a couple of workarounds adding a post-processing step after Inkscape result is retrieved.
For CMYK, if we use icc-color(cmyk, 1, 1, 0, 0)
attributes and replace them after with the correspondent device-cmyk(1,1,0,0)
attributes is ok.
For spot colours, the workaround is similar however a bit more trickier given that we need to use intermediate placeholders. For example use icc-color(spot-1)
than afterwards will be translated to icc-named-color(profile, 'Cool Red (102))
.
We didn't find any other attribute except icc-color
to work on for this workaround. Is there a list of SVG attributes that are accepted by Inkscape parsing? And values those attributes can hold? Does it follow any kind of validation?
Is there a way of preventing any of these attributes to be removed?. Any options on the command line that I've missed?
I've included a test.svg too.
Thank you very much!