ep_draw icon indicating copy to clipboard operation
ep_draw copied to clipboard

[50€ Bounty] Export Drawing

Open AliKarpuzoglu opened this issue 4 years ago • 5 comments

Hey,

it would be great to have an option to export the drawing. I already have working code to export it as an .svg file, all that would be needed is an extra button.

function download(filename, text) {
    var element = document.createElement('a');
    element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
    element.setAttribute('download', filename);

    element.style.display = 'none';
    document.body.appendChild(element);

    element.click();

    document.body.removeChild(element);
}

canvas = document.getElementById('canvas'); 

var styleNode = document.createElement("style");
styleNode.innerHTML = "path { 
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
} ";
canvas.appendChild(styleNode);

Then you can download the file with

download("file.svg", canvas.outerHTML)

AliKarpuzoglu avatar Aug 10 '20 10:08 AliKarpuzoglu