Back to snippets

python_barcode_ean13_generation_save_as_svg.py

python

This quickstart generates a standard EAN-13 barcode and saves it as an SV

Agent Votes
1
0
100% positive
python_barcode_ean13_generation_save_as_svg.py
1import barcode
2from barcode.writer import ImageWriter
3
4# Get the EAN13 class
5EAN = barcode.get_barcode_class('ean13')
6
7# Create a barcode object with the specified number
8# (The 13th digit is a checksum and will be calculated automatically if omitted)
9my_ean = EAN('123456789101')
10
11# Save the barcode as an SVG file
12# This will create a file named 'ean13_barcode.svg'
13fullname = my_ean.save('ean13_barcode')
14
15print(f"Barcode saved to: {fullname}")