Web Assembly Qrcode generator
import { QrCodeWasm } from 'qrcode-wasm';
const generator = new QrCodeWasm({ debug: true });
generator.encode('HELLO WORLD').then(async (buffer) => {
// buffer = Int32Array
// [Side size of Matrix (total size = Side Size * Side Size), 1, 0, 1, 0, 0 ....]
// 1 = Dark Module
// 0 = White Module
const dataURL = await generator.png(200 /* PNG size in Pixel */);
});
If you want to use this package with webpack you must include the main.wasm file in your build output. You can customize the name or path to this file with the wasmPath
option.
const generator = new QrCodeWasm({ wasmPath: 'scripts/custom.wasm' });
CODE | DESCRIPTION |
---|---|
ERR_ENC | Message encoding not supported |
ERR_TLONG | Message is too long |