如何保存Raphael生成的svg [英] How to save an svg generated by raphael

查看:163
本文介绍了如何保存Raphael生成的svg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以将raphael生成的SVG保存为svg文件.请注意,它仅需要在chrome中工作.

Is there a way to save the SVG generated by raphael as an svg file. Note it only need to work in chrome.

推荐答案

使用Blob API .

As stef commented, the BlobBuilder API is deprecated. Instead, use the Blob API.

Andreas的答案为基础,这是我快速使其工作的方式:

Building on Andreas' answer, here is how I quickly got it to work:

svgString = r.toSVG();
a = document.createElement('a');
a.download = 'mySvg.svg';
a.type = 'image/svg+xml';
blob = new Blob([svgString], {"type": "image/svg+xml"});
a.href = (window.URL || webkitURL).createObjectURL(blob);
a.click();

这篇关于如何保存Raphael生成的svg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆