Skip to main content

Get Started - Generate a QR Code

  • 2 minutes to read

Important

You need a license for the DevExpress Office & PDF File API Subscription or DevExpress Universal Subscription to use these examples in production code.

This tutorial uses DevExpress.Docs.Barcode API to generate a QR Code image a .NET application.

Typical Barcode Generation Workflow

  1. Choose symbology from the supported barcode list.
  2. Configure common options (colors, layout, DPI, module size).
  3. Set symbology-specific options (for example, QR Code error correction).
  4. Export a barcode image and embed it in your application or documents.

Create a .NET Application and Generate a QR Code

This section follows the workflow above to generate the following barcode:

Barcode_Result

  1. Create a new Console App project for .NET 8 or later.

  2. Install the DevExpress.Docs.Barcode NuGet package.

  3. Open the Program.cs (Module1.vb) file. Paste the code below in the Main method of the Program class (Main procedure of the Module1 module in Visual Basic):

    using System.IO;
    using DevExpress.Docs.Barcode;
    using DevExpress.Drawing;
    
    // Choose a symbology
    var qrOptions = new QRCodeOptions();
    
    // Configure common options
    qrOptions.Dpi = 96;
    qrOptions.ModuleSize = 2f;
    qrOptions.ShowText = false;
    
    // Configure QR Code-specific options
    qrOptions.CompactionMode = QRCodeCompactionMode.Byte;
    qrOptions.ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.Q;
    
    // Export the barcode image
    using var output = new FileStream("BarCodeImage.png", FileMode.Create, FileAccess.Write);
    using var generator = new BarcodeGenerator(qrOptions);
    generator.Export("https://www.devexpress.com", output, DXImageFormat.Png);
    
  4. Run the project. The image is saved as BarCodeImage.png.

View Example: Create and display a BarCode in a web application

Next Steps

See Also