Skip to content

Instantly share code, notes, and snippets.

@psbolden
Created March 7, 2017 16:52
Show Gist options
  • Save psbolden/c5b2c0a09d2956f5bacd61a6730f8c43 to your computer and use it in GitHub Desktop.
Save psbolden/c5b2c0a09d2956f5bacd61a6730f8c43 to your computer and use it in GitHub Desktop.
download fabric canvas to url with name
http://stackoverflow.com/questions/20032214/recreate-fabric-js-canvas-and-export-as-an-image
function download(url,name){
// make the link. set the href and download. emulate dom click
$('<a>').attr({href:url,download:name})[0].click();
}
function downloadFabric(canvas,name){
// convert the canvas to a data url and download it.
download(canvas.toDataURL(),name+'.png');
}
//now when you want to download the canvas call
downloadFabric(canvas,'<file name>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment