UNPKG

shopcham-rn-genbarcode

Version:

gen base64 barcode (CODE128,QRcode,EAN13) thank and this project modified react-native-smart-code package

27 lines (20 loc) 561 B
import { NativeModules } from 'react-native'; const codeGenerator = NativeModules.RNCodeGeneratorModule; const Type = { Code128: codeGenerator.Code128, EAN13: codeGenerator.EAN13, QRCode: codeGenerator.QRCode }; class CodeGenerator { static async generate({ type = Type.Code128, code, width=300, height=300 }) { const base64Str = await codeGenerator.generateCode({ type, code, width, height }); return 'data:image/png;base64,'.concat(base64Str); } } CodeGenerator.Type = Type; export default CodeGenerator;