This short tutorial will teach you how to generate Barcode image in C# by providing details about the environment configuration and usage of different classes and functions to perform the task. A runnable C# Barcode generator code will also be provided to demonstrate the feature. At the end of the code, the Barcode image will be saved as PNG. You can save it in other formats also like BMP, JPEG, etc.
Steps to Generate Barcode Image in C#
- Configure the project to add Aspose.BarCode using the NuGet Package Manager
- Add necessary namespaces in the program
- Create and initialize BarCodeGenerator class object
- Specify the Barcode encoding type as Code128 using EncodeTypes and the code text
- Save the generated Barcode image on the disk
These steps entails the details about the necessary resources required to run the sample code. First, the BarCodeGenerator class object is declared and initialized that contains all the functions and properties required to generate Barcode using C#. In the final steps, the generated Barcode is saved as an image after setting the encoding type and a its text string.
Code to Create Barcode using C#
The EncodeTypes enumerator contains a lot of other encodings also like EAN-13 and EAN-8, ITF-14, Code39, QR Code, GS1 Code, and others. This is quite a simple code, however you can set a lot of properties for the Barcode like adjusting the Barcode appearance in terms of size, rotation angle, resolution, border settings, and paddings.
In this tutorial, we have learned how with the help of C# Barcode can be generated. If you want to learn other features like rotating a Barcode, refer to the article how to rotate Barcode image in C#.