Image barcodeImage = barcodLib.Encode(TYPE.CODE128, NumericString, foreColor, backColor, imageWidth, imageHeight)
We just need to change barcode type in the code placed here // Generate the barcode with your settings Once you will execute above code in your C# Console app, you can see barcode image will be generate at at "D:\Barcode.png", here is the output of the image note: you must have permission to save file in the specified ImageFormat.Png) Store image in some path with the desired format Image barcodeImage = barcodLib.Encode(TYPE.CODE11, NumericString, foreColor, backColor, imageWidth, imageHeight) Generate the barcode with your settings Int imageHeight = 110 //barcode image heightĬolor foreColor = Color.Black // Color to print barcodeĬolor backColor = Color.Transparent //background color Int imageWidth = 250 // barcode image width Once you have installed the Nuget package, we can now use it to generate barcode, so in your Program.cs, you can write the code as below Step 3: Generate barcode in C# using BarCodeLib If you decide to create an instance with parameters, the parameters are as follows: the string is the data to be encoded into the barcode, and BarcodeLib.TYPE is the symbology to encode the data with.
Select your project in which you want to install this, and click "Install".īarcodelib library, contains a class called BarcodeLib with three constructors: Barcode() Now, we need to install BarCodeLib Nuget package, which we will use to generate barcode using C# code, so navigate to "Tools"-> "Nuget Package Manager" -> "Manage nuget package for this solution" -> Select "Browse" tab and search for "BarcodeLib". Step 2: Install BarcodeLibe Nuget package using Nuget Package manager Open your Visual Studio, and navigate to File-> New -> Project -> Select "Windows Classic" from left-pane and "Console app (.NET Framework)", provide the name "CSharpBarcodeGenerator" and click "Ok" I will be creating C# console application in Visual Studio to show example to generate barcode in C#, but you can use the same C# code in Win-Forms or MVC web-app or Web-Forms.( You may have to modify few things like image path etc.) Step 1: Create a new Console app in Visual Studio to generate or read barcode in C# It is quite common to generate barcode or QR Code in C# web-application or win-form application while working on any E-commerce related project.In one of the previous post, we have mentioned how you can generate QR Code in C# MVC project usng, so in this post, I will explaining how we can generate barcode in C# using Nuget package Barcodelib.