I need to do a svg export png image function.
First I generate svg to base64, with the base64 header type too svg+xml, then
var image=new Image();
image.src=base64Code;
image.onload = function() {
      var canvas = document.createElement('canvas');
      var context = canvas.getContext('2d');
      canvas.width = image.width;
      canvas.height = image.width;
      context.drawImage(image, 0, 0);
      png = canvas.toDataURL("image/png",1);
}`
My canvas.width/height may be very large.
When I use canvas.toDataURL it returns "data:;".
When the canvas.width/height is more reasonable, the result is correct.
Is there any good way to deal this? Or use javascript to convert from svg+xml to .png?
 
     
     
     
    