A bit of theory about barcodes
It is difficult to imagine our life without barcodes, especially now that we meet them at every step. We go to the cinema and our tickets contain this “black and white drawing of bars”, we go to the supermarket and each product has information about it in the form of a barcode. We can only imagine what the queues would be if the cashier entered the product identifiers manually, without using a scanner. Moreover, there is a great risk of making a mistake when entering a sequence of numbers. Today we will consider a small part of all kinds of barcodes.
ITF (Interleaved Two of Five) or “2 of 5 interleaved” barcode - is a dual-band numeric code, or a high density numeric barcode that can encode only pairs of numbers (the barcode must have an even number of digits!). Each barcode pattern encodes the odd digit in the pattern of bars and the even digit in the pattern of spaces between bars. To encode an odd number of digits you must pad the left most (most significant) digit with a zero.
Barcodes can be of variable length and do not normally use a checksum, although a modulo 10 check character is used in some special situations. Partial scans are possible since bar code 2 of 5 interleaved is not self-checking, and fixed length data fields are often used to circumvent this problem.
- Encodes numeric-only data;
- The length is variable, but must have an even number of digits;
- The checksum is optional.
As ITF is the barcode with very high data density, it offers the following features:
- The label size can be smaller than those of other codes with the same digits. It is effective to print barcodes in small spaces.
- More data can be contained compared with other codes, if the label size is same. (Number of digits can be increased.)
- Wider bar width is possible, if the label size and the number of digits are same.
If the bar width is wider, it is easy for the barcode reader to read. The reading with long distance can also be performed.
Although ITF has many advantages, it also has the disadvantage of possible "skip reading" due to its composition. Skip reading means that the barcode representing "3852" is incorrectly read as "38" with some digits being skipped.
Both ITF-14 and GTIN-14 barcodes are generated using the “Interleaved 2 of 5” symbology. The ITF-14 is used on shipping containers and is based on the UPC code. Usually, Interleaved barcodes are printed on corrugated cardboard boxes, that contain goods for delivery and have the following structure:
Industrial 2 of 5 was developed by Identicon Corp. and Computer Identics Corp. in 1970, and was actively used in industrial applications. However, it is currently not used (except for some logistics applications). Industrial 2 of 5 looks like this and uses 5 bars to represent one character. Since this code only assigns data to bars (and not to spaces), it has very low data density:
Matrix 2 of 5 is a higher density member of the Code 2 of 5 symbology family, which was first developed in 1968. It has been used primarily in warehouse sorting and photo finishing. The "2 of 5" name derives from the fact that of the five elements (bars and spaces) that are used to encode each character, two are wide and three are narrow.
Barcode fine adjustment in Delphi and Lazarus for printing
FastReport VCL allows you to use all three types of barcodes. Let’s see how to do it.
In the FastReport VCL designer, add the obCatBarcode component to the report and select the type of the barcode from the list:
Code – area for the numeric value of the barcode;
Type of Bar – the type of the barcode can be changed immediately in the editor without adding a new component to the report;
Calc CheckSum – checksum. All linear barcodes have this property. Remember “skip reading”? We must fight it somehow! This property determines whether the checksum should be calculated automatically. If it is disabled, the checksum must be present in the object text;
Zoom – sets the scaling of the barcode and is used only in conjunction with the “Autosize” property;
Text – enable / disable display of text under the barcode;
Rotation – allows you to set the rotation of the object to one of the fixed angles – 0, 90, 180, 270 degrees.
Check the consistency of the generated barcode (fortunately, the camera and the barcode scanning program are now available in all modern smartphones).
Creating a barcode from the Delphi / Lazarus code
Now we know a little more about ITF barcodes and can use them for our reports, labels, and many other things.