One of the major improvements in TX Text Control X9 is the integrated support for barcodes of type TX Barcode .NET. This barcode component, available for Windows Forms and WPF, enables developers to integrate barcodes into .NET based applications. In today's processes, barcodes are included everywhere: Invoices, delivery notes or admission tickets. Barcodes are used to store digital data on paper that can be acquired easily for further processing using laser-based scanners, cameras or mobile phones.

In order to insert a barcode, an object of type BarcodeFrame and the associated TXBarcodeControl object is required. The BarcodeFrame acts like a container for barcodes in TX Text Control and can be added to the collection of barcodes.

The following code shows how to create these two objects and how to insert them into the current document:

TXTextControl.Barcode.TXBarcodeControl txBarcode1 =
                new TXTextControl.Barcode.TXBarcodeControl(); 

txBarcode1.BarcodeType = 
                TXTextControl.Barcode.BarcodeType.QRCode; 
txBarcode1.UpperTextLength = 19; 
txBarcode1.Text = "www.textcontrol.com"; 

TXTextControl.DataVisualization.BarcodeFrame bf = 
                new TXTextControl.DataVisualization.BarcodeFrame(txBarcode1); 

textControl1.Barcodes.Add(bf, -1);

The barcode is inserted at the current input position in it's default size:

TX Barcode .NET in TX Text Control

Understanding the UpperTextLength Property

TX Barcode .NET has been designed for word processing purposes. For reporting and other word processing requirements, it is essential that the barcode object doesn't displace other objects or text in the document. Therefore, the size must be fixed and the inner content should be resized instead.

This can be controlled using the UpperTextLength property of TX Barcode .NET. This property defines the maximum number of characters. If the maximum number of characters is encrypted, it fills the complete space of the object.

If less charactes are encrypted, the barcode size doesn't change, but the content is getting smaller. In the above sample, the UpperTextLength property is set to a number of 19 and the encrypted text has exactly 19 characters. The following screenshot shows what happens, if the encryted text is shorter than 19 characters:

TX Barcode .NET in TX Text Control

But what if the barcode object size gets changed?

TX Barcode .NET in TX Text Control

The barcode content is scaled proportionally based on the object size and the UpperTextLength.

Consider a typical scenario: A barcode should be added for each item line in a product list. The barcode encrypts the article code of each product in that list. In this case, the article code length stays constant and in most cases, you know the length of the article codes in advance. Then you can set the UpperTextLength property of the barcode to the length of the article codes and the barcode size stays constant.

In case the barcode text length is variable, and you would like to use the AutoSize functionality of TX Barcode .NET, you should set the UpperTextLength property for each instance to the length of the encrypted text before setting the text. This ensures that the barcode content fills the container completely.

string sText = "Flow Type Layout Reporting";

txBarcode1.UpperTextLength = sText.Length;
txBarcode1.Text = sText;

Start today and download fully featured, 30 day trial versions