WhyNotHugo / python-barcode

㊙️ Create standard barcodes with Python. No external dependencies. 100% Organic Python.
http://python-barcode.rtfd.io/
MIT License
573 stars 124 forks source link

Is there EAN14 support? Trouble with EAN14 #103

Open moreplavec opened 3 years ago

moreplavec commented 3 years ago

Just simple question: is it possible to use it to generate EAN14? PyPi says it is possible to use it for EAN14 (https://pypi.org/project/python-barcode/), but doc says just EAN13.

Thanks for the answer.

WhyNotHugo commented 3 years ago

Yes, it's ean14 or barcode.ean.EuropeanArticleNumber14 (e.g.: all the docs for EAN13 apply, just replace 13 with 14).

It's documented in the latest master, but not in the last stable release. Those docs will be published with the next release.

moreplavec commented 3 years ago

Thanks for fast replay, but i have problem reading EAN14 barcodes. No problem with EAN13, but EAN14 is "somehow" wrong?

I tried to generate EAN14 form product IDs:

for product in products:
    code = product.ID.get_text().strip()    
    length = len(code)
    produkt_id_10 = (10 - length) * '0' + str(code)
    ean14_bez = '104' + produkt_id_10 # EAN14 without last digit
    ean14 = barcode.get('ean14', ean14_bez) # EAN14 with last digit
    ean14_barcode = ean14.save(ean14)

This will generate EAN14 barcodes named as EAN14 number. But it's impossible to read them. Please, try:

EAN14 barcode generated, but unreadable: https://svgshare.com/s/TC_ EAN14 barcode generated, but read as EAN13 with my reader: https://svgshare.com/s/TDk

Do you know what's wrong?

moreplavec commented 3 years ago

I tried to find what's wrong and triend another solutions. It generates same last digit, but all EAN14 generators i tried added (01) at the beginning of the barcode. I found this info: "the first two numbers are the Application Identifier of the EAN-128: (01). You cannot change them. They are part of the code.". Maybe it should be added to generator?

WhyNotHugo commented 3 years ago

Sorry, missed this comment.

So there should be in total of 16 digits, with the leading 01?