ArtQRCode icon indicating copy to clipboard operation
ArtQRCode copied to clipboard

Is there a way to generate these codes on NodeJs, as we cannot use dom there?

Open aliarshad9691 opened this issue 4 years ago • 3 comments

I am trying to generate bulk codes in a project. generating them on browser does not seems a good idea... Is there a possibility to generate codes server side?

aliarshad9691 avatar Jan 16 '21 10:01 aliarshad9691

Yes, it is possible you need to take the data from users and send it back to the server where QRcode will be generated and they will be stored as temporary files just (like we do with bytes io in python) and send back to the client.

tazim404 avatar Jul 13 '21 17:07 tazim404

maybe u can use Headless browser

XingXiaoWu avatar Dec 02 '21 03:12 XingXiaoWu

I am able to generate on server side, by adding follwoing lines on top of artqrcodejs

import {Canvas} from 'canvas';
import {JSDOM} from 'jsdom';
const dom = new JSDOM('<!DOCTYPE html><div id="qr"></div>');
var document = dom.window.document;
global.Image = Canvas.Image;

i'll make a PR, so this library can be used on server side as well. This is very helpful for bulk qrCode generation.

aliarshad9691 avatar Dec 02 '21 04:12 aliarshad9691