yWorks / svg2pdf.js

A javascript-only SVG to PDF conversion utility that runs in the browser. Brought to you by yWorks - the diagramming experts
MIT License
654 stars 100 forks source link

svg element fill="currentColor" #132

Closed derMart closed 1 year ago

derMart commented 4 years ago

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 commented 4 years ago

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

HackbrettXXX commented 4 years ago

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

HackbrettXXX commented 3 years ago

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.

yGuy commented 3 years ago

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().

Mrfence97 commented 3 years ago

Hi guys,

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

edemaine commented 2 years ago

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