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.
In short:
- 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:
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.
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:
Next, go to the barcode editor:
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).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
uses frxBarcod; procedure TForm1.Button1Click(Sender: TObject); var bc: TfrxBarcodeView; begin bc :=TfrxBarcodeView(frxReport1.FindObject('BarCode1')); {Set the type of the barcode} bc.BarType := bcCode_2_5_interleaved; {Set the fixed barcode value} bc.Text := '123456'; {Set the calculated barcode value} //bc.Expression := '<YourDatasetName."FieldName1"> + <YourDatasetName."FieldName2">'; {Set whether it is necessary to calculate the checksum and add it to the end of the barcode} bc.CalcCheckSum := False; {Set the scale at which the barcode will be displayed} bc.Zoom := 2; {Set the angle of the barcode rotation. Can take the following values: 0, 90, 180, 270} bc.Rotation := 0; {Set whether to set the width of the barcode depending on its content.} {If set to False, Zoom will be set to keep the barcode width fixed} bc.AutoSize := True; {Set the barcode background color} bc.Color := clNone; {Set the barcode lines color} bc.ColorBar := clBlack; {Set whether to display the text at the bottom of the barcode} bc.ShowText := True; frxReport1.ShowReport(); end; |
Now we know a little more about ITF barcodes and can use them for our reports, labels, and many other things.