Live stream set for 2025-04-15 at 14:00:00 Eastern
Ask questions in the live chat about any programming or lifestyle topic.
This livestream will be on Odysee or you can watch below.
Creating And Reading Barcodes
A barcode is a method of representing machine-readable images consisting of black and white bars.
Multiple tools are available for generating barcodes. Some are command-line only such as zint, while others have a GUI such as Zint Barcode Studio.
In a 1D barcode, data is scanned in a linear sequence using a series of vertical lines and spaces of varying widths to encode data.
There are many different types of 2D barcodes such as QR code and Aztec code. QR codes are matrix barcodes that can contain alphanumeric and binary data. A popular use of QR codes is to share a link to a website for people with mobile devices.
In this tutorial, the Zint Barcode Studio will be used to encode data in a different barcodes. Zint Barcode Studio is free, open source and cross-platform (Mac, Windows and Linux) and integrates seamlessly with popular IDEs The test will consist of encoding simple text, then URLs and finally an address book entry in vCard format.
Requirements For Barcode Generator
Glossary:
GUI
Graphical User Interface allows users to interact with electronic devices through graphic icons and indicators.
1D
One-dimensional or linear.
2D
Two-dimensional developed, using geometric patterns like rectangles, dots, and hexagons.
Data Matrix
Two-dimensional barcode with uniquely generated patterns of square modules.
GS1 Composite
Two-dimensional barcode with 2 components, top for batch codes or expiry and bottom for item identification number.
Common Barcodes
Name | Description | Example |
---|---|---|
1D Barcode | Scanned horizontally and can hold 85 characters. | Universal Product Code (UPC). |
2D Barcode | Scanned horizontally and vertically and can hold 7089 characters. | QR Code. |
2D Barcode | Scanned horizontally and vertically and can hold 7089 characters. | Aztec Code. |
2D Barcode | Scanned horizontally and vertically and can hold 7089 characters. | Data matrix. |
2D Barcode | Scanned horizontally and vertically and can hold 7089 characters. | GS1 Composite code. |
Name | Description | Example |
Generate Barcodes Via Zint
# Create Text Link In Barcode # zint -b "https://ojambo.com" # Create Text Link In QR Code # zint -b QRCODE -o qrcode1.png -d "https://ojambo.com" # Add Boundary Bars And Boxes # zint --box --border=10 -w 10 -d "Ojambo Website" -o box.png # Create Text Address Book Entry In QR Code # cat > vcard.vcf << 'EOF' BEGIN:VCARD VERSION:3.0 FN:Edward Ojambo N:Ojambo;Edward;;; EMAIL;type=HOME,INTERNET:edward@ojamboshow.local URL:https://ojambo.com END:VCARD EOF zint -b QRCODE -o address.png -i vcard.vcf
Download
The Zint library can be downloaded from Zint Library and installed on your workstation.
Explanation
- Generate a file with your QR code.
- Test the QR Code on your scanning device such as a smartphone.
- Optionally tweak the width and height of the border in pixels.
- In order to generate a VCF-encoded QR code, place the contents in a separate file (literal VCF).
- The library accepts a string or a list of data chunks.





Usage
You can use the zint command line tool to generate barcodes using the default settings. For this tutorial, QR codes were generated for plain text, URL and vCard. Barcodes were generated for plain text for static data storage to dynamic user engagement. You can use generated QR codes for even ticketing and product information among other uses.
Open Source
Zint, including the encoding library, is released under a dual license. The encoding library is released under the BSD (3 clause) license, while the GUI, Zint Barcode Studio, and the CLI are released under the GNU General Public License version 3 or later. The permissive license requires the preservation of the copyright notice and disclaimer, while the copyleft license comes with strict rules and requirements to ensure the software remains free and open-source. It allows commercial use, modification, distribution, and allows making derivatives proprietary, consult the license for more specific details.
Conclusion:
Zint is currently able to encode data in over 50 barcodes. The rendered image can be either PNG, BMP, GIF, PCX, EPS or SVG.
If you enjoy this article, consider supporting me by purchasing one of my OjamboShop.com Online Programming Courses or publications at Edward Ojambo Programming Books or simply donate here Ojambo.com Donate
References:
- Zint Barcode Encoding Library
- Customer Sets Price Plugin for WooCommerce on Ojambo.com
- Learning JavaScript Course on OjamboShop.com
- Learning Python Course on OjamboShop.com
- Learning PHP Course on OjamboShop.com
- Learning JavaScript Paperback on Amazon
- Learning JavaScript Ebook on Amazon
- Learning Python Ebook on Amazon
- Learning PHP Ebook on Amazon
- OjamboServices.com For Custom Websites, Applications & Tutorials