Advanced QR Code Writing

C# + VB.Net: Advanced QR Code Writing Advanced QR Code Writing
using System;
using IronBarCode;
using System.Drawing;  // Include a reference to System.Drawing.Dll



/*** GENERATING QR CODES WITH THE QRCODEWRITER CLASS ***/

// Using the QRCodeWriter.CreateQrCodeWithLogo Method instead of BarcodeWriter.CreateBarcode exposes additional QR creation options.
// Choosing a high QRCodeWriter.QrErrorCorrectionLevel makes QR codes more fault tolerant and faster to read
GeneratedBarcode RandomQR = QRCodeWriter.CreateQrCode(Guid.NewGuid().ToString(), 500, QRCodeWriter.QrErrorCorrectionLevel.Highest);
RandomQR.AddAnnotationTextAboveBarcode("Your Random Key is" + RandomQR.Value).SaveAsJpeg("RandomQR.jpeg");



/*** STYING QR CODES WITH LOGO IMAGES OR BRANDING ***/

// Use the QRCodeWriter.CreateQrCodeWithLogo Method instead of BarcodeWriter.CreateBarcode
// Logo will automatically be sized appropriately and snapped to the QR grid.

GeneratedBarcode QRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://visualstudio.microsoft.com/", "visual-studio-logo.png");
QRWithLogo.ResizeTo(500, 500).SetMargins(10).ChangeBarCodeColor(Color.DarkGreen);
QRWithLogo.SaveAsPng("QRWithLogo.Png").SaveAsPdf("MyVerifiedQR.html"); // save as 2 formats 
Imports System
Imports IronBarCode
Imports System.Drawing ' Include a reference to System.Drawing.Dll



'''* GENERATING QR CODES WITH THE QRCODEWRITER CLASS **

' Using the QRCodeWriter.CreateQrCodeWithLogo Method instead of BarcodeWriter.CreateBarcode exposes additional QR creation options.
' Choosing a high QRCodeWriter.QrErrorCorrectionLevel makes QR codes more fault tolerant and faster to read
Private RandomQR As GeneratedBarcode = QRCodeWriter.CreateQrCode(Guid.NewGuid().ToString(), 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
RandomQR.AddAnnotationTextAboveBarcode("Your Random Key is" & RandomQR.Value).SaveAsJpeg("RandomQR.jpeg")



'''* STYING QR CODES WITH LOGO IMAGES OR BRANDING **

' Use the QRCodeWriter.CreateQrCodeWithLogo Method instead of BarcodeWriter.CreateBarcode
' Logo will automatically be sized appropriately and snapped to the QR grid.

Dim QRWithLogo As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo("https://visualstudio.microsoft.com/", "visual-studio-logo.png")
QRWithLogo.ResizeTo(500, 500).SetMargins(10).ChangeBarCodeColor(Color.DarkGreen)
QRWithLogo.SaveAsPng("QRWithLogo.Png").SaveAsPdf("MyVerifiedQR.html") ' save as 2 formats

Iron Barcode allows a developer to create QR codes with more options than they do for creating normal barcodes. For example, we can set QR error correction levels, we can color QR codes, and we can also add logos.

If a logo is added to a QR code, it is automatically resized to an appropriate dimension where the QR can still be read and then snapped to grid so that it is aligned perfectly with the black-and-white squares on the QR image.