Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the npm module gs1-barcode-parser?

I want to extract the price value from the GS1 data martix QR code value using Nodejs. Using the module

npm i gs1-barcode-parser

Tried the below throwing "parseBarcode" is not a function

const { parseBarcode } = require('gs1-barcode-parser');
let barcode = '\u001d01093393871222863922001405\u001d1522030631030006691095751410';
console.log(parseBarcode(barcode));
like image 727
Udhaya Avatar asked Jan 27 '26 09:01

Udhaya


1 Answers

I would use the modded module gs1-barcode-parser-mod2

const parser = require("gs1-barcode-parser-mod2")

let barcode = ']C101040123456789011715012910ABC1233932978471131030005253922471142127649716';
console.log(parser.parseBarcode(barcode));

Unfortunately your barcode seems to be invalid. You will need to decode from UTF-8 as that would result in ∞01093393871222863922001405∞1522030631030006691095751410 even then your barcode seems to have a missing prefix, called an Application Identifier or for short, AI (]xxxxx..).

A valid barcode example is given in the code snippet above.

More info about application identifiers

like image 99
Jesse de gans Avatar answered Jan 29 '26 00:01

Jesse de gans



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!