Integrating Aztec Code Generation in C#

A professional developer's guide to using cruflbcsnet.dll for high-performance barcode encoding.

Implementation Details

1

Add a project reference to cruflbcsnet.dll and include the using crUFLBcsNet; directive.

2

Apply the bcsaztec.ttf font to the resulting string to render the barcode visually.

AztecGenerator.cs
using System;
using crUFLBcsNet; // Ensure DLL is referenced

namespace AztecEncodingApp
{
    class Program
    {
        static void Main(string[] args)
        {
            // Initialize the Barcodesoft Aztec Object
            crUFLBcsNet.CAztec aztec = new crUFLBcsNet.CAztec();

            string inputData = "Hello, World!";

            // Method 1: Standard Encoding
            string str = aztec.Encode(inputData);
            Console.WriteLine("Standard Output: " + str);

            // Method 2: Advanced Encoding for Crystal Reports (EncodeCR)
            // Param 1: Input String
            // Param 2: Index (Always 0)
            // Param 3: Format (0 = Auto Selection)
            // Param 4: Error Correction (0 = Default 23%)
            string str2 = aztec.EncodeCR(inputData, 0, 0, 0);

            Console.WriteLine("Crystal Reports Output: " + str2);

            // IMPORTANT: Format the output strings with bcsaztec.ttf font
        }
    }
}
Parameter Value SEO Description
Index 0 Sequence index for barcode placement.
Format 0 Enables automatic selection for optimal Aztec sizing.
Error Correction 0 Applies a standard 23% error correction level.

Aztec Code Image Full Source Code Implementation

Program.cs
// 1. Required Namespaces
using System;
using System.IO;
using Barcodesoft.Aztec; 

namespace AztecExample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Instantiate the barcode engine
            CAztec aztec = new CAztec();

            // Generate the image as a byte array 
            // Parameters: Data, Width, Height, Format (2=PNG), ErrorLevel
            byte[] aztecImage = aztec.Image("Hello, World!", 0, 0, 2, 0);

            if (aztecImage != null)
            {
                // Persist the byte array to a physical file
                File.WriteAllBytes("myAztecBarcode.webp", aztecImage);
                Console.WriteLine("Aztec barcode saved successfully.");
            }
        }
    }
}