How to generate a QR code barcode as a PNG file using C# in .NET Framework
QR codes are the most robust type of barcode, with a variety of useful applications in advertising, web design, and even POS systems. Today we will be looking at how to quickly generate QR codes from any text string. To keep things simple, let’s skip the heavy coding and use an API. To do this, we will need to first install the API client by pasting this command into your Package Manager console:
Install-Package Cloudmersive.APIClient.NET.Barcode -Version 1.2.4
Then call GenerateBarcodeQRCode and provide it with a string to be encoded.
using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NET.Barcode.Api;
using Cloudmersive.APIClient.NET.Barcode.Client;
using Cloudmersive.APIClient.NET.Barcode.Model;namespace Example
{
public class GenerateBarcodeQRCodeExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new GenerateBarcodeApi();
var value = value_example; // string | QR code text to convert into the QR code barcodetry
{
// Generate a QR code barcode as a PNG file, a type of 2D barcode which can encode free-form text information
System.IO.Stream result = apiInstance.GenerateBarcodeQRCode(value);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling GenerateBarcodeApi.GenerateBarcodeQRCode: " + e.Message );
}
}
}
}
Your output will be a PNG image file. For example here is the output for “The quick brown fox jumps over the lazy dog.”

Easy. If you need other barcode related functionality, this API also allows barcode lookups and is able to generate UPC and EAN type barcodes as well.
