JsBarcode icon indicating copy to clipboard operation
JsBarcode copied to clipboard

Barcodes with lower case format (such as "codabara") are not initialized properly by init() from HTML code

Open janjonas opened this issue 4 years ago • 1 comments

The following HTML code does not render a barcode in format "codabar" but results in the following error:

JsBarcode.all.js:1509 Uncaught TypeError: Encoder is not a constructor at encode (JsBarcode.all.js:1509) at JsBarcode.all.js:1583 at ErrorHandler.wrapBarcodeCall (JsBarcode.all.js:1194) at API.init (JsBarcode.all.js:1579) at index.html:7

< script src="JsBarcode.all.js" > < svg id="barcode" jsbarcode-format="codabar" jsbarcode-value="A01234567890A" jsbarcode-height="100"> < script>JsBarcode("#barcode").init();

I found the following line

var Encoder = _barcodes2.default[options.format.toUpperCase()];

and was able to fix the issue by replacing it with

var Encoder = _barcodes2.default[options.format.toUpperCase()] || _barcodes2.default[options.format.toLowerCase()];

I'm not sure if this is the right place to fix the bug, but it seems to be a general problem with barcode formats in lower case.

janjonas avatar Jun 27 '20 10:06 janjonas

Maybe codabar and pharmacode should be updated to be in all caps, like the rest of the barcode encoders?

kurmachu avatar Sep 01 '22 22:09 kurmachu