P粉6688042282023-08-24 18:10:17
jbeard4 solution works well.
I'm using Raphael SketchPad to create the SVG. Link to the file from step 1.
For the "Save" button (the id of svg is "editor" and the id of canvas is "canvas"):
$("#editor_save").click(function() { // the canvg call that takes the svg xml and converts it to a canvas canvg('canvas', $("#editor").html()); // the canvas calls to output a png var canvas = document.getElementById("canvas"); var img = canvas.toDataURL("image/png"); // do what you want with the base64, write to screen, post to server, etc... });
P粉5949413012023-08-24 00:54:48
The following is the method implemented through JavaScript: