lindell / JsBarcode

Barcode generation library written in JavaScript that works in both the browser and on Node.js
http://lindell.me/JsBarcode
MIT License
5.5k stars 1.11k forks source link

Support for gs1-128? #321

Closed adsad213 closed 4 years ago

adsad213 commented 4 years ago

Hello I've searched through previous issues and documentation and no answer for my issue could be found; to archieve a gs1-128 code you need to prepend (have the prefix) with a FNC1 character that is 0xf1, wrapping around code128 and when I try to generate a code with that prefix, I get the error "Uncaught [CODE] is not a valid input for e". What am I doing wrong? Thanks!

SanichKotikov commented 4 years ago

https://github.com/lindell/JsBarcode/wiki/CODE128#ean128-option-for-code128

adsad213 commented 4 years ago

that doesn't work @SanichKotikov , I've mentioned I tried that.

SanichKotikov commented 4 years ago

Works fine for me https://github.com/lindell/JsBarcode/blob/master/src/barcodes/CODE128/CODE128.js#L32

adsad213 commented 4 years ago

I'll test it out. Thanks for the help!

skylarmt commented 4 years ago

Is it possible to specify the ean128 option from HTML? Something like jsbarcode-ean128=true?

thomasvst commented 2 years ago

Hi @SanichKotikov ! Can you confirm this is the right way to encode a SSCC-18 Barcode ? SSCC : [FNC1] 00 12345678 0000000001 (see https://en.wikipedia.org/wiki/GS1-128) let sscc = "123456780000000001"; JsBarcode("#barcode", "\xCF00" + sscc, { format: "CODE128C", ean128: true });

What if my EAN128 contains multiple application identifier ? Exemple : [FNC1] 21 12345 [FNC1] 11 090101 17 100101 I've tried to insert multiple \xCF in the value but I get an error : "xxx is not a valid input for e" JsBarcode("#barcode", "\xCF2112345\xCF1109010117100101", { format: "CODE128C", ean128: true });

Thanks !

SanichKotikov commented 2 years ago

Hi,

See https://github.com/lindell/JsBarcode/blob/master/src/barcodes/CODE128/CODE128.js#L32

I'm not sure about multiple identifier, but maybe this will help you:

const code = '\xCF' + '21' + '12345' + '\xCF' + '11' + '090101' + '17' + '100101';
JsBarcode('#barcode', code, {format: "CODE128"});
thomasvst commented 2 years ago

Hi,

I've tried the following :

const FNC1 = '\xCF';

JsBarcode("#bc1", FNC1 + '02' + ean, {
    format: "CODE128",
    ean128: true
});

JsBarcode("#bc3", FNC1 + '02' + ean, {
    format: "CODE128C",
    ean128: true
});

No one is recognized by my ZEBRA scanner.

But this seams to work (without the ean128 option) :

JsBarcode("#bc2", FNC1 + '02' + ean, {
    format: "CODE128"
});

This sounds logic, the scanner is expecting the application identifier (FNC1).