
Barcodes are used to visually represent the data in a machine-readable form. Most often, barcodes appear to be a means of a product’s identification. Various types of barcodes are used in different scenarios such as Code128, Code11, Code39, QR, Datamatrix, Aztec and etc. In this article, you will learn how to programmatically generate the barcodes using C#. Furthermore, you will see how to customize the appearance of a barcode.
- C# Barcode Generator API
- Generate a Barcode using C#
- Generate QR Barcode using C#
- Customize the Appearance of a Barcode in C#
- Add Caption in Barcode using C#
Generate Barcodes with C# Barcode API – Free Download
Aspose.BarCode for .NET is a powerful barcode generator and scanner API that lets you generate and read a wide range of barcode symbologies including but not limited to:
- Code128
- Code11
- Code39
- QR
- Datamatrix
- EAN13
- EAN8
- ITF14
- PDF417
- and more.
You can download the API for free or get it installed within your .NET application using the NuGet.
PM> Install-Package Aspose.BarCode
Generate a Barcode using C#
The following are the steps to generate a barcode using Aspose.BarCode for .NET.
- Create an object of BarcodeGenerator class and specify the barcode’s type and text in its constructor.
- Set barcode’s features such as resolution and etc.
- Generate barcode using BarcodeGenerator.Save(String) method.
The following code sample shows how to generate a barcode using C#.

Generate a QR Barcode using C#
You can generate other types of barcodes in a similar way. For the demonstration, let’s generate a QR barcode which is one of the widely used barcode symbologies. The following are the steps to generate a QR barcode.
- Create an object of BarcodeGenerator class and specify the barcode’s type as EncodeTypes.QR.
- Generate barcode using BarcodeGenerator.Save(String) method.
The following code sample shows how to generate a QR barcode using C#.

Customize the Appearance of a Barcode in C#
You can also customize the appearance of the barcode by changing its font, forecolor, background color, text’s color, and etc. The following are the steps to customize a barcode using Aspose.BarCode for .NET.
- Create an instance of BarcodeGenerator class.
- Set the barcode’s appearance using BarcodeGenerator.Parameters properties i.e. BarcodeGenerator.Parameters.BackColor.
- Generate barcode using BarcodeGenerator.Save(String) method.
The following code sample shows how to generate a customized Aztec barcode using C#.

Add Caption in Barcodes using C#
You might have seen barcodes with a caption above or below the barcode image. These captions can be used to display additional information related to the product or the barcode itself. Aspose.BarCode for .NET also allows you to add a caption below, above, or on both sides of the barcode. The following are the steps to add a caption.
- Create an object of BarcodeGenerator class.
- Set the barcode’s text and type in the constructor of BarcodeGenerator.
- Set caption using CaptionAbove or CaptionBelow properties.
- Save the barcode using BarcodeGenerator.Save(String) method.
The following code sample shows how to add caption in a barcode using C#.

Conclusion
In this article, you have learned how to generate barcodes programmatically using C#. In addition, you have seen how to customize a barcode by modifying its appearance. You can explore more about the C# barcode generator API using documentation.