Created
March 7, 2017 16:52
-
-
Save psbolden/c5b2c0a09d2956f5bacd61a6730f8c43 to your computer and use it in GitHub Desktop.
download fabric canvas to url with name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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