I'm utilizing canvg
to convert my d3 generated svg
graph into different download formats. All of my data is contained in rectangle nodes and wrapped to fit the specified width. In SVG, the text looks perfect with the wrapping code. Here's how the element is setup:
<text text-anchor="middle" alignment-baseline="middle" x="0" opacity="1.5716901593992887">
<tspan x="0" y="-1em" dy="1.25em">regulation</tspan><tspan x="0" y="-1em">GO:0009889</tspan>
<tspan x="0" y="-1em" dy="2.1999999999999997em">of</tspan>
<tspan x="0" y="-1em" dy="3.1499999999999995em">biosynthetic</tspan><tspan x="0" y="-1em" dy="4.1em">process</tspan>
</text>
Again, the text looks perfect on the SVG, but when transformed to canvg
, it looks differently:
https://i.stack.imgur.com/SCCAq.jpg (the left being svg, which looks correct and the right being canvas, which doesn't look correct/is downshifted)
How is d3 elements transferred over through canvg
that makes it different in the output? If this issue is not fixable, are there other alternatives to convert svg elements into a pdf/png file?