Learn how to use Java to create several different types of bar codes and explains how these barcodes work to encode data. iText 7 library supports many barcodes. iText 7 supports only two types of 2D barcodes: QR codes and Data Matrixes. Let’s start with QR codes as this barcode is pretty common these days.

In my previous article, I reviewed the basics of iText 7. Here, I focus on the barcode support provided by the iText 7 library. Firstly, I’ll provide a short overview of barcodes, and then demonstrate barcode generation for every supported barcode type in the library.

Overview

Here is a simple definition of ‘barcode’ according to Wikipedia:

A barcode or bar code is a method of representing data in a visual, machine-readable form.

Most barcode standards are managed by the GS1 organization. If you want to see some examples of barcodes, please check the barcode sheet on their site. In general, we recognize two basic barcode types:

  • Linear or one-dimensional (1D).
  • Matrix or multi-dimensional (2D).

iText 7 library supports many barcodes, but not all the options mentioned on Wikipedia. Nevertheless, I believe the library supports all the common ones. The section dedicated to 1D barcodes contains some generalization as there are five supported barcodes. Therefore, I’ll begin with an explanation of generating the 2D barcodes, because there are only two of them.

Prerequisite: All the codes below, expect iText 7, are basic knowledge. Please check my previous article where I covered that. Additionally, my project has recently been upgraded to the latest libraries (Spring Boot 2.4.2 and iText 7.1.14).

2D Barcodes

Matrix or multi-dimensional (2D) barcodes are represented by black and white “dots.” These barcodes are compact and capable of holding high-capacity symbols in the unit area.

iText 7 supports, as already mentioned, only two types of 2D barcodes: QR codes and Data Matrixes. Let’s start with QR codes as this barcode is pretty common these days.

#java #itext #programming #developer

Using Barcodes in iText 7
2.55 GEEK