I need to convert an svg element to png. while converting to png the text is getting overlapped and not aligning properly.
The actual image is like this: enter image description here
The Image after conversion is like this:
The code is something like this:
//This piece of code comes under svg element
<text class="foreignObject" text-anchor="middle" x="43.37111015014165" dy="0" width="85.7422203002833" clip-path="url(#area_clip392N6)" y="1em" iname="0" style="fill: rgb(255, 255, 255);">
<tspan x="43.37111015014165" y="1em" dy="0em">data for area map</tspan>
<tspan x="43.37111015014165" y="1em" dy="1.1em">from backend -</tspan>
<tspan x="43.37111015014165" y="1em" dy="2.2em">data for area map</tspan>
<tspan x="43.37111015014165" y="1em" dy="3.3000000000000003em">from backend -</tspan>
<tspan x="43.37111015014165" y="1em" dy="4.4em">data for area map</tspan>
<tspan x="43.37111015014165" y="1em" dy="5.5em">from backend</tspan>
</text>
//-------------------------------------------------------------------------------------------------------------------------------
//This is the code which I used to convert svg to png:
var c = document.createElement('canvas');
c.width = item.clientWidth;
c.height = item.clientHeight;
canvg(c, angular.element(item).find("svg").parent().html());
imgData['url'] = c.toDataURL('image/png');
I have not updated the canvg.js file before.Now I have updated and it is working fine.