Barcodes, specially two dimensional matrix barcodes like QR codes, are common place nowadays. So the C# developers often question how to generate QR code in C# applications. This can be done quickly with few lines of code using Aspose.BarCode for .NET.
You can easily create barcodes or QR code in your .NET applications, including Windows applications, or Web applications using C# with the steps given in this answer.
Steps to Generate QR Code in C#
- Nuget package of Aspose.BarCode for .NET is required first
- Next, use Aspose.Barcode and Aspose.BarCode.Generation namespaces
- Add Aspose license using SetLicense method
- Now, create an instance of BarCodeGenerator Class and set QR as encode type
- Set code text which you want to add to the QR code
- Set required properties of the DocumentBuilder object
- As a last step, save QR code as image format
In this example, we’re saving the QR code image as PNG, however, you can save your QR code in Bmp, Gif, Jpeg, PNG, Tiff, TiffInCmyk, EMF, or SVG image formats. You just need to pass the image format while saving the generated QR code.
Example for Generating QR Code in C#
If you’re developing your own QR code generator or adding this QR generation feature in your application, the steps and sample given above can save you a lot of time and effort.