svgraphael

How to save an svg generated by raphael


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


Solution

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

    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();