Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aliarshad9691 opened this issue Jan 16, 2021 · 3 comments

Comments

@aliarshad9691
Copy link

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?

@tazim404
Copy link

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.

@XingXiaoWu
Copy link

maybe u can use Headless browser

@aliarshad9691
Copy link
Author

aliarshad9691 commented Dec 2, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants