Eric Shiroe
Eric Shiroe

Reputation: 31

How download base64 data as image?

I use vue-signature Library and I Don't know how to download base64 data generated as image, Here is Link of library : https://www.npmjs.com/package/vue-signature I've already read the documentation and see That "Save()" Methods Save image as PNG/JPG… but it give me base64 data, thank you for your collaboration, I use vue js

Upvotes: 2

Views: 9206

Answers (1)

CookieThief
CookieThief

Reputation: 168

This is not the most optimized solution, But it works.

var a = document.createElement("a"); //Create <a>
a.href = "data:image/png;base64," + ImageBase64; //Image Base64 Goes here
a.download = "Image.png"; //File name Here
a.click(); //Downloaded file

In your case you can try this

var canvas = document.querySelector("canvas");

var signaturePad = new SignaturePad(canvas);

// Returns signature image as data URL (see https://mdn.io/todataurl for the list of possible parameters)
signaturePad.toDataURL("image/jpeg"); // save image as JPEG

source : https://vuejsexamples.com/vue-signature-pad-component/

Upvotes: 8

Related Questions