Skip to content

Instantly share code, notes, and snippets.

@lgg
Created January 6, 2022 03:00
Show Gist options
  • Save lgg/8af97b169b32f3a7c1513bde98db4ea6 to your computer and use it in GitHub Desktop.
Save lgg/8af97b169b32f3a7c1513bde98db4ea6 to your computer and use it in GitHub Desktop.
Save SVG from HTML5 Canvas

Save SVG from Canvas

tags: Save/download/get/parse SVG image from HTML5 html web js javascript canvas

example websites: https://www.vectorizer.io/

Insert this code to JavaScript console:

var svgData = $("#outputsvg")[0].outerHTML;
var svgBlob = new Blob([svgData], {type:"image/svg+xml;charset=utf-8"});
var svgUrl = URL.createObjectURL(svgBlob);
var downloadLink = document.createElement("a");
downloadLink.href = svgUrl;
downloadLink.download = "newesttree.svg";
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment