相关疑难解决方法(0)

将Raphael JS在画布中生成的SVG另存为png的问题

我正在尝试转换由Raphael JS(和用户,因为您可以拖动和旋转图像)生成的SVG .我在浏览器中跟踪了这个转换SVG图像(JPEG,PNG等),但仍然无法获得它.

它一定很容易,但我不能指责我错了.

我得到了我在一个div与SVG #ec作为id与画布的一个#canvas.

function saveDaPicture(){
    var img = document.getElementById('canvas').toDataURL("image/png");
    $('body').append('<img src="'+img+'"/>');
}
$('#save').click(function(){
    var svg = $('#ec').html();
    alert(svg);
    canvg('canvas', svg, {renderCallback: saveDaPicture(), ignoreMouse: true, ignoreAnimation: true});
});
Run Code Online (Sandbox Code Playgroud)

警报给了我:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="600" height="512">
<desc>Created with Raphael</desc>
<defs></defs>
<image x="0" y="0" width="300" height="512" preserveAspectRatio="none" href="imageurl.jpg"></image>
<rect x="168" y="275" width="52" height="70" r="0" rx="0" ry="0" fill="none" stroke="#000" stroke-dasharray="8,3" transform="rotate(21.91207728 194 310)" style="opacity: 1; display: none; " opacity="1"></rect>
<circle cx="50" …
Run Code Online (Sandbox Code Playgroud)

javascript jquery svg canvas raphael

8
推荐指数
2
解决办法
1万
查看次数

标签 统计

canvas ×1

javascript ×1

jquery ×1

raphael ×1

svg ×1