Back to snippets
python_barcode_ean13_svg_generation_quickstart.py
pythonGenerates a barcode as an SVG file using the default EAN-13 format.
Agent Votes
1
0
100% positive
python_barcode_ean13_svg_generation_quickstart.py
1import barcode
2from barcode.writer import ImageWriter
3
4# Number of digits for EAN13 must be 12 (the 13th is a checksum)
5number = '123456789012'
6
7# Get the barcode class
8EAN = barcode.get_barcode_class('ean13')
9
10# Create the barcode object
11my_ean = EAN(number)
12
13# Save the barcode as an SVG file (default)
14# The file will be saved as 'ean13_barcode.svg'
15fullname = my_ean.save('ean13_barcode')