Skip to content

Bar Codes

Bar Codes

https://scanbot.io/blog/types-of-barcodes/

from barcode.writer import ImageWriter
from barcode import generate, get_barcode

#['CODABAR', 'Code128', 'Code39', 'Dict', 'EAN13', 'EAN13_GUARD', 'EAN14', 'EAN8', 'EAN8_GUARD', 'Gs1_128', 'ISBN10', 'ISBN13', 'ISSN', 'ITF', 'JAN', 'Optional', 'PROVIDED_BARCODES', 'PZN', 'UPCA', 'Union', '__BARCODE_MAP', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'base', 'charsets', 'codabar', 'codex', 'ean', 'errors', 'generate', 'get', 'get_barcode', 'get_barcode_class', 'get_class', 'isxn', 'itf', 'os', 'upc', 'version', 'writer']
TESTCODES = (
    ("ean8", "40267708"),
    ("ean8-guard", "40267708"),
    ("ean13", "5901234123457"),
    ("ean13-guard", "5901234123457"),
    ("ean14", "12345678911230"),
    ("upca", "36000291453"),
    ("jan", "4901234567894"),
    ("isbn10", "3-12-517154-7"),
    ("isbn13", "978-3-16-148410-0"),
    ("issn", "1144875X"),
    ("code39", "Example Code 39"),
    ("pzn", "487780"),
    ("code128", "Example Code 128 998866"),
    ("itf", "12341234"),
)

for codename, code in TESTCODES:
	bcode = get_barcode(codename, code)
	print(f"Code: {bcode.name}, Value: {code}")
	#bcode.save(bcode.name)
	print(f"{bcode.to_ascii()}")

"""
Code: EAN-8, Value: 40267708
| | |   ||   || |  |  || | |||| | | |   |  |   |  |||  | |  |   | |
Code: EAN-8 with guards, Value: 40267708
| | |   ||   || |  |  || | |||| | | |   |  |   |  |||  | |  |   | |
Code: EAN-13, Value: 5901234123457
| |   | || |  ||| ||  ||  |  || |||| |  ||| | | | ||  || || ||  |    | | |||  |  ||| |   |  | |
Code: EAN-13 with guards, Value: 5901234123457
| |   | || |  ||| ||  ||  |  || |||| |  ||| | | | ||  || || ||  |    | | |||  |  ||| |   |  | |
Code: EAN-14, Value: 12345678911230
| |  |  || |||| |  ||| | ||   |    | |  |   | | | |  |   ||| |  ||  || ||  || || ||  |    | |||  | | |
Code: UPC-A, Value: 36000291453
|_|_||||_|_|_||||___||_|___||_|___||_|__|__||_|_|_|||_|__||__||_|_|||__|__|||_|____|_|||_|__|_|
Code: JAN, Value: 4901234567894
| |   | || |  |||  ||  |  |  || |    |  ||| | | | |  ||| | |    |   |  |  |   ||| |  | |||  | |
Code: ISBN-10, Value: 3-12-517154-7
| | ||| ||   |  | |    |  ||  |  || || ||   | | | ||  || |   |  |   |  | |
Code: ISBN-13, Value: 978-3-16-148410-0
| | ||| ||   |  | |    |  ||  |    | |  ||  | | | | |||  |  |   | |||  ||  || |||  | |||  | | |
Code: ISSN, Value: 1144875X
| | ||| ||  |   | ||  ||  ||  |  ||| | |   || | | |  ||| | |
Code: Code 39, Value: Example Code 39
X   X XXX XXX X XXX X XXX   X X X   X XXX X XXX XXX X X   X XXX XXX XXX X X   X X XXX XXX X   X X XXX X X   XXX XXX X XXX   X X X   XXX X XXX X XXX XXX X   X X XXX X XXX X   X X X XXX   X XXX XXX X XXX   X X X   XXX X XXX X XXX XXX   X X X X XXX   X XXX X XXX   XXX X X X X   X XXX XXX X
Code: Pharmazentralnummer, Value: 487780
X   X XXX XXX X X XXX XXX X   X X   XXX XXX X X X X XXX X   XXX X   X X XXX XXX X X   XXX X XXX XXX X   X XXX X X X   X XXX XXX X X   X XXX XXX XXX X   X XXX X X X   XXX XXX X X X   XXX XXX X X   X XXX XXX X
Code: Code 128, Value: Example Code 128 998866
XX X  X    X   XX X   XXXX  X  X X  X XX    XXXX XXX X X X  XXXX  XX  X X    X XX  X    XX XX  XX  X   X   XX X   XXXX X X    X  XX X XX  X    XX XX  XX  X  XXX  XX XX  XXX  X XXX X  XX  XX XX  XX  X XXX XXXX X XXX XXXX XXXX  X  X X  X    XX XX    X X  XX   XXX X XX
Code: ITF, Value: 12341234
XX  XX  XXXXX  XX     XX  XX  XXXXX     XXXXX  XXXXX  XX     XX  XX     XXXXX  XX     XX  XX  XXXXX     XXXXX  XXXXX  XX     XX  XX     XXXXX  XX
[Finished in 122ms]
"""

Codecs

IAN8/EAN8 (International/European Article Number 8)

  • Shorter version of EAN13 of only 8 numbers

IAN13/EAN13 (International/European Article Number 13)

  • 13-digit number
    • First 3 digits are GS1 prefix which denote the country
    • Next section is the Manufacturer code
    • Next section is the Product code
    • The last 13th digit is a check bit

They can encode 13-digit numeric codes, including the country code, manufacturer code, product code, and check digit.

IAN14/EAN14 (International/European Article Number 14)

UPC-A (Universal Product Code)

  • 12-digit number
    • First 6 digits are the Company Prefix
    • Next 5 digits are the item number
    • 12 digit is a check bit

JAN

ISBN-10

ISBM-13

ISSN

Code 39

Pharmazentralnummer

GTIN-14

Code 128

ITF

1D Barcodes

Codabar

  • 7 bars and spaces represent one character.
    • Inclues range of [0-9A-D-\$\/.+]
    • Any one of A, B, C or D (a, b, c or d) is attached to the start and end of the barcode. (start/stop character)
  • Uses
    • Slips for door-to-door delivery service (example in Japan)
    • Codabar is also applied to the test tube for blood test (specimen) in order to confirm the individual ID.

ITF

Industrial 2 of 5

Standard 2 of 5 (IATA)

Code 39

  • Up to 43 characters [A-Z0-9*\ -\$\%.\/+]

MSI Plessey

Code 93

Code 128

GS1–128