Barcodes are used in various applications to connect the electronic world with a paper document or to gain access to additional information. TX Text Control supports the following barcode types:

  • 14 one-dimensional barcodes including Code 39 and EAN.
  • 6 two-dimensional barcodes including QR, DataMatrix and PDF417.

Adding Barcodes Programmatically

The following code uses a ServerTextControl TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
ServerTextControl Class
The ServerTextControl class implements a component that provide high-level text processing features for server-based applications.
object to insert QR code into a new document.

// new non-UI ServerTextControl
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
// create a new Barcode object
TXTextControl.Barcode.TXBarcodeControl txBarcode1 =
new TXTextControl.Barcode.TXBarcodeControl();
var sBarcodeText = "";
txBarcode1.BarcodeType =
txBarcode1.UpperTextLength = sBarcodeText.Length;
txBarcode1.Text = sBarcodeText;
txBarcode1.Name = "uniqueId";
// create a Barcode frame object
TXTextControl.DataVisualization.BarcodeFrame bf =
new TXTextControl.DataVisualization.BarcodeFrame(txBarcode1);
// add the frame with the Barcode to the document
tx.Barcodes.Add(bf, -1);
view raw test.cs hosted with ❤ by GitHub

The integrated barcodes have been designed for document processing purposes. For these 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 is controlled by the UpperTextLength property. 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 characters are encrypted, the barcode size doesn't change, but the content is getting smaller.

Merge Data into Barcodes

Any barcode can be dynamically filled with data during the merging process of the MailMerge TX Text Control .NET Server for ASP.NET
DocumentServer Namespace
MailMerge Class
The MailMerge class is a .NET component that can be used to effortlessly merge template documents with database content in .NET projects, such as ASP.NET web applications, web services or Windows services.
class. The Name property of a barcode is used in the same way like merge fields to merge data. In the above code snippet, the Name property is set in line 16. Now, consider the following JSON merge data:

"name":"Product A",
"name":"Product B",
view raw data.json hosted with ❤ by GitHub

In a template, the data field uniqueId is bound to the barcode placeholder object:

Creating barcodes with TX Text Control

The following code merges JSON data into a template that contains the barcode placeholder:

// new non-UI ServerTextControl
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
// loda a template
tx.Load("App_Data/template.tx", TXTextControl.StreamType.InternalUnicodeFormat);
// load data from file
var sData = System.IO.File.ReadAllText("App_Data/data.json");
// merge data
using (TXTextControl.DocumentServer.MailMerge mm =
new TXTextControl.DocumentServer.MailMerge()) {
mm.TextComponent = tx;
// save the document into a byte array
byte[] document;
tx.Save(out document, TXTextControl.BinaryStreamType.AdobePDF);
view raw test.cs hosted with ❤ by GitHub

The following screenshot shows the resulting PDF with the merged QR Code:

Creating barcodes with TX Text Control

See this live in one of our online demos:

Live Demos

Or test this on your own and download the fully-functional trial version.