下载Svg,因为png无法在IE11上运行

时间:2016-08-08 13:04:22

标签: javascript d3.js svg

需要下载svg d3图。我已经使用saveSvgAsPngJpgSvg来启动下载。代码适用于所有其他期望IE11的浏览器。 Fiddle

我试过了:



svgAsDataUri(svg, {}, function(svg_uri) {
		render_width=1000;
		render_height=1000;
		 var canvas = document.createElement('canvas');
 			 canvas.height = render_height;
  		     canvas.width = render_width;
 			 document.body.appendChild(canvas);

  // Create an image and draw the SVG onto the canvas
 		 var image = new Image;
 			 image.onload = function() {
  			  canvas.getContext('2d').drawImage(this, 0, 0, render_width, render_height);
 			 };
  image.src = svg_uri;
  setTimeout(function(){//download_in_ie(canvas, 'filename' + '.png'); 
  	if (canvas.msToBlob) { //for IE
                var blob = canvas.msToBlob();
                window.navigator.msSaveBlob(blob, 'dicomimage.png');
            }
}, 3000);

    
			});




使用msSaveBlob按照给定的link结果建议安全错误

我怎样才能实现这个目标?

0 个答案:

没有答案