davidshimjs / qrcodejs

Cross-browser QRCode generator for javascript
MIT License
13.51k stars 4.75k forks source link

How do I get the dataURL as a js-variable #260

Open eagle275 opened 2 years ago

eagle275 commented 2 years ago

As mentioned - I don't need the generated QR as an image / canvas / table inside my website, but instead want to print it out client-side .. we already have a working method of exporting PDF which will then be printed and I want to export the generated qr-code through this method so the user can print "his" QR Code So if possible I want to use the dataURL - or even the base64 code of the generated PNG Any ideas and help are much appreciated

tarcisioreis commented 2 years ago

See that suggestion, https://stackoverflow.com/questions/9626863/export-canvas-dataurl-as-pdf-how-dataurl-is-too-long-to-pass-to-server

And in code, it's create a dynamic image see this code:

image

Hope this helps

badalsaibo commented 2 years ago
const div = document.createElement('div');
new QRCode(div, "http://jindo.dev.naver.com/collie");
const src = div.children[0].toDataURL("image/png");
console.info('src', src);

https://github.com/davidshimjs/qrcodejs/issues/160#issuecomment-517582403

eagle275 commented 2 years ago

thx for your answers @heyDante and @tarcisioreis