How to Generate QR Code in C#

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#

  1. Nuget package of Aspose.BarCode for .NET is required first
  2. Next, use Aspose.Barcode and Aspose.BarCode.Generation namespaces
  3. Add Aspose license using SetLicense method
  4. Now, create an instance of BarCodeGenerator Class and set QR as encode type
  5. Set code text which you want to add to the QR code
  6. Set required properties of the DocumentBuilder object
  7. 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.

 English