In this blog we'll learn to creating barcode using python, here we'll be learning creating barcode in 3 different ways:
- Creating barcodes as SVG
- Creating barcodes as Image
- Create barcodes from the commandline
Note: Pillow is necessary for image output (png, jpg), but not for SVG export.
To make a barcode, you only need to know the system (EAN, UPC, etc.) and the code (e.g. for EAN-13: 123456789102). As you can see, the checksum is calculated automatically, thus you don't need it. The checksum is optional on some systems (Code 39), in which case you can use the add checksum keyword parameter (default is True).
Rapsberry Pi Pico Barcode & QR Code Scanner HAT & Breakout - Launched
Creating barcodes as SVG
Scan QR Codes with Raspberry Pi Pico https://t.co/aoVl6ZvTMn
— Finex (@finexpofficial) December 2, 2021
Creating barcodes as Image
Create barcodes from the commandline
Barcodes
- Code 39
- Code 128
- PZN
- EAN-13
- EAN-8
- JAN
- ISBN-13
- ISBN-10
- ISSN
- UPC-A
Code 39
barcode.codex.
Code39
(code, writer=None, add_checksum=True)Initializes a new Code39 instance.
Parameters: - code : String
Code 39 string without * and checksum (added automatically if add_checksum is True).
- writer : barcode.writer Instance
The writer to render the barcode (default: SVGWriter).
- add_checksum : Boolean
Add the checksum to code or not (default: True).
get_fullcode
()Returns the full code, encoded in the barcode.
Returns: Full human readable code. Return type: String
render
(writer_options=None, text=None)Renders the barcode using self.writer.
Parameters: - writer_options : Dict
Options for self.writer, see writer docs for details.
- text : str
Text to render under the barcode.
Returns: Output of the writers render method.
Class Hirarchy
Code 128
New in version 0.8beta1.
- class
barcode.codex.
Code128
(code, writer=None) Initializes a new Code128 instance. The checksum is added automatically when building the bars.
Parameters: - code : String
Code 128 string without checksum (added automatically).
- writer : barcode.writer Instance
The writer to render the barcode (default: SVGWriter).
get_fullcode
()Returns the full code, encoded in the barcode.
Returns: Full human readable code. Return type: String
render
(writer_options=None, text=None)Renders the barcode using self.writer.
Parameters: - writer_options : Dict
Options for self.writer, see writer docs for details.
- text : str
Text to render under the barcode.
Returns: Output of the writers render method.
Class Hirachy
PZN
barcode.codex.
PZN
alias of
barcode.codex.PZN7
Class Hirarchy
EAN-13
- class
barcode.ean.
EuropeanArticleNumber13
(ean, writer=None, no_checksum=False) Initializes EAN13 object.
Parameters: - ean : String
The ean number as string.
- writer : barcode.writer Instance
The writer to render the barcode (default: SVGWriter).
build
()Builds the barcode pattern from self.ean.
Returns: The pattern as string Return type: String
calculate_checksum
()Calculates the checksum for EAN13-Code.
Returns: The checksum for self.ean. Return type: Integer
get_fullcode
()Returns the full code, encoded in the barcode.
Returns: Full human readable code. Return type: String
render
(writer_options=None, text=None)Renders the barcode using self.writer.
Parameters: - writer_options : Dict
Options for self.writer, see writer docs for details.
- text : str
Text to render under the barcode.
Returns: Output of the writers render method.
to_ascii
()Returns an ascii representation of the barcode.
Return type: String
Class Hirarchy
EAN-8
- class
barcode.ean.
EuropeanArticleNumber8
(ean, writer=None) Represents an EAN-8 barcode. See EAN13’s __init__ for details.
Parameters: - ean : String
The ean number as string.
- writer : barcode.writer Instance
The writer to render the barcode (default: SVGWriter).
build
()Builds the barcode pattern from self.ean.
Returns: The pattern as string Return type: String
Class Hirarchy
JAN
- class
barcode.ean.
JapanArticleNumber
(jan, writer=None) Initializes JAN barcode.
Parameters: - jan : String
The jan number as string.
- writer : barcode.writer Instance
The writer to render the barcode (default: SVGWriter).
Class Hirarchy
ISBN-13
- class
barcode.isxn.
InternationalStandardBookNumber13
(isbn, writer=None) Initializes new ISBN-13 barcode.
Parameters: - isbn : String
The isbn number as string.
- writer : barcode.writer Instance
The writer to render the barcode (default: SVGWriter).
Class Hirarchy
ISBN-10
- class
barcode.isxn.
InternationalStandardBookNumber10
(isbn, writer=None) Initializes new ISBN-10 barcode. This code is rendered as EAN-13 by prefixing it with 978.
Parameters: - isbn : String
The isbn number as string.
- writer : barcode.writer Instance
The writer to render the barcode (default: SVGWriter).
Class Hirarchy
ISSN
- class
barcode.isxn.
InternationalStandardSerialNumber
(issn, writer=None) Initializes new ISSN barcode. This code is rendered as EAN-13 by prefixing it with 977 and adding 00 between code and checksum.
Parameters: - issn : String
The issn number as string.
- writer : barcode.writer Instance
The writer to render the barcode (default: SVGWriter).
Class Hirarchy
UPC-A
- class
barcode.upc.
UniversalProductCodeA
(upc, writer=None, make_ean=False) Universal Product Code (UPC) barcode.
UPC-A consists of 12 numeric digits.
build
()Builds the barcode pattern from ‘self.upc’
Returns: The pattern as string Return type: str
calculate_checksum
()Calculates the checksum for UPCA/UPC codes
Returns: The checksum for ‘self.upc’ Return type: int
get_fullcode
()Returns the full code, encoded in the barcode.
Returns: Full human readable code. Return type: String
render
(writer_options=None, text=None)Renders the barcode using self.writer.
Parameters: - writer_options : Dict
Options for self.writer, see writer docs for details.
- text : str
Text to render under the barcode.
Returns: Output of the writers render method.
to_ascii
()Returns an ascii representation of the barcode.
Return type: str
Class Hirarchy
Posts You May like:
- The New Version of Raspberry Pi OS, Debian "Bullseye" is Now Available.
- The Raspberry Pi Zero 2 W Arrives Six Years After The First Pi Zero
- Raspberry Pi 4 Has Been Given Vulkan 1.1 Compliance by Khronos
- The Raspberry Pi Build HAT - Complete Guide
- Raspberry Pi Officialy Announced Build HAT For Raspberry Pi
- Installing Android on a Raspberry Pi 4 with Google Play Store
- Pop OS Linux is Coming to Raspberry Pi and Other ARM Devices Soon
- How to Immediately Upgrade to Windows 11
- A Secret Update for the Raspberry Pi 4 8GB
- Raspberry Pi Introduces a New Documentation Hub
- Quick start with ESP8266 based Pico WiFi HAT
- Capture local Real-Time Air Quality Data with Raspberry Pi Pico
- GitHub CLI 2.0 Is Now Available, With Extension Support
- Connecting Wi-Fi on Raspberry Pi Pico Become Easy
- How To Track All Devices with Raspberry Pi
- Make your own Raspberry Pi Image from scratch
- How to Send phone notifications Using Raspberry Pi Pico?
- Raspberry Pi Pico 4G/2G Expansion : Expectations vs. Reality
- Quick Example to Drive Servo Using Programmable I/O
- How to Use a USB SSD or Flash Drive to Boot a Raspberry Pi 4 / Pi 400
- Filter Ads by your Raspberry Pi Before they Reach your Devices
- A Raspberry Pi 4 Model A Launch 2022 - Eben Upton
- First-Ever 2G Expansion Board for Raspberry Pi Pico has Launched on Kickstarter
- Learn IoT "Internet of Things" with 24 lessons for Teachers and Students
- Quick Guide for Raspberry Pi Users: Raspberry Pi Terminal Commands
- Windows 11 on Raspberry Pi Devices in Easy Installation Guide
- Get Your Project Done by Raspberry Pi Approved Design Partners
- PiRelay 8 Smart Relay Board for Raspberry Pi - Kickstarter
- Tiny Round/Circular LCD Display Launched!
- Issue Fixed! USB Boot Ubuntu Server 20.04 on Raspberry Pi 4
- HC-SR04 Sensor with micro-ROS on the Raspberry Pi Pico
- Raspberry Pi Pico: ADC Sampling and FFT
- Using CircuitPython for RP2040
- How to Setup Pico RP2040 on Windows
- Using micro-ROS on the Raspberry Pi Pico
- LED Tricks Using The Raspberry Pi Pico
- The RP2040 Raspberry Pi Pico Meets LoRa
- Pico supports SD cards and FatFS
- How to connect a Raspberry Pi Pico to LoRaWAN
- 50 Raspberry Pi Hacks & Tips You Should Know
- How to Install Wi-Fi and Internet on a Raspberry Pi Pico