jeromeetienne / jquery-qrcode

qrcode generation standalone (doesn't depend on external services)
http://blog.jetienne.com/blog/2011/04/07/jquery-qrcode/
MIT License
4.84k stars 2.5k forks source link

how to get toDataURL of generated qr #46

Open mikekay01 opened 11 years ago

mikekay01 commented 11 years ago

I want to use the generated QR code other places in my project. Is it possible to get the image from the canvas using toDataURL? I know generally how to use toDataURL, but the problem is the canvas generated in your script has no id so I don't know how to reference it...

mikekay01 commented 11 years ago

Let me add a comment. I read previously that others were asking if you could write the qr code directly into an existing canvas. If that is possible it will fix my issue. I am basically trying to generate a qr code and place it into another canvas. the toDataURL is being used as an interim step to get an image.

realuserofgit commented 10 years ago

Note in IE8 toDataURL() is not working

edoreld commented 7 years ago

I would also like to get this working

ghostcs commented 5 years ago

can be done like this

var dataURL = $('canvas')[0].toDataURL("image/png"); console.log(dataURL);

window.open().document.write('<img src="' + dataURL + '" />');