I am using canvg lib to convert svg to png but some how when my svg size is more than 10000 it fails to draw it on canvas and data-URL get only "data:;" empty
here is my code that I am using
function getDiagramImage(isTrue,_callback){
var html = d3.select("svg")
//.attr("version", 1.1)
//.attr("xmlns", "http://www.w3.org/2000/svg")
.attr({
'xmlns': 'http://www.w3.org/2000/svg',
'xmlns:xmlns:xlink': 'http://www.w3.org/1999/xlink',
version: '1.1'
})
.node().parentNode.innerHTML;
d3.select('#hiddenCanvas').attr('width',_canvasWidth).attr('height',(parseFloat(_canvasHeight) + 300) );
var canvas = document.getElementById('hiddenCanvas');
var context = canvas.getContext("2d");
canvg(document.getElementById('hiddenCanvas'), html, {
renderCallback: function() {
var dataURL = canvas.toDataURL();
if(!isTrue){
var pngimg = '<img src="'+dataURL+'">';
d3.select("#pngdataurl").html(pngimg);
var a = document.createElement("a");
a.download = "export_"+Date.now()+".png";
a.href = dataURL;
document.body.appendChild(a);
a.click();
}
if(_callback){
_callback(dataURL);
}
}
});
}
About This function .. there d3.js code which create diagram. and one save and download button is there save will get data URL to png and save it on server while download will download image instantly.. same function work for both with arguments .
Issue comes with "renderCallback " while svg is large that data URL comes empty I tried with timeout also but it's not get me result and timer keep running