svg2pdf.js icon indicating copy to clipboard operation
svg2pdf.js copied to clipboard

svg element fill="currentColor"

Open derMart opened this issue 6 years ago • 6 comments

I am not sure if this is a bug or I took the wrong approach or this even does not belong to the svg spec. When embedding an svg into html you can specify <path fill="currentColor" .../> to let the fill color be determined by the 'parent' scope. I tried the same using svg2pdf.js but it just draws nothing. I tried to specify doc.setFillColor('#000000'); before drawing the svg into the doc, but it didn't help either.

Is it possible to use the currentColor value while drawing an svg using svg2pdf.js?

kind regards Martin

derMart avatar Mar 30 '20 15:03 derMart

update: it does belong to the svg spec: https://www.w3.org/TR/SVG11/color.html#ColorProperty

derMart avatar Mar 30 '20 15:03 derMart

The currentColor property is not supported by svg2pdf. We are happy about pull requests, though.

HackbrettXXX avatar Mar 31 '20 10:03 HackbrettXXX

For an implementation, we need to add a color property to the AttributeState and read this value in parseAttributes if the value of an attribute is currentColor.

HackbrettXXX avatar Sep 23 '20 14:09 HackbrettXXX

This is a nice feature to have, especially in the conjunction with use elements as differently-colored glyphs. I am using this in some of my apps, so currently this would not really work with the export. Specifying the state from outside is also possible, of course, but that would require an API change, I guess. I think I would rather not overload the meaning of document.setFillColor().

yGuy avatar Sep 23 '20 14:09 yGuy

Hi guys,

I've raised a pull request #158 that (mostly) implements currentColor. Please feel free to make any further edits if required!

Mrfence97 avatar Oct 22 '20 21:10 Mrfence97

Given that #158 has been merged, I take it this issue can be closed?

edemaine avatar May 09 '22 21:05 edemaine