How to Generate DotCode Barcodes Using Aspose.BarCode for .NET

How to Generate DotCode Barcodes Using Aspose.BarCode for .NET

This article shows how to generate DotCode barcodes with Aspose.BarCode for .NET in C#. DotCode is a specialized 2D barcode for industrial, logistics, and direct part marking applications due to its ability to encode data quickly and reliably on curved, rough, or difficult surfaces.

Real-World Problem

Manufacturers and logistics providers often need to label products, parts, or packaging in environments where typical barcodes cannot be applied. DotCode is uniquely suited for DPM (direct part marking), high-speed logistics, and automation lines, but most .NET barcode tools do not support this format.

Solution Overview

Aspose.BarCode for .NET supports full DotCode generation, allowing developers to create durable, machine-readable barcodes for industrial or high-volume environments, with customizable size and layout.


Prerequisites

Before you start, ensure you have:

  1. Visual Studio 2019 or later
  2. .NET 6.0 or later (or .NET Framework 4.6.2+)
  3. Aspose.BarCode for .NET installed via NuGet
  4. Basic knowledge of C#
PM> Install-Package Aspose.BarCode

Step-by-Step Implementation

Step 1: Install and Import Aspose.BarCode

Install the NuGet package and import the required namespaces:

using Aspose.BarCode.Generation;

Step 2: Create the DotCode Barcode Generator

Instantiate the generator for DotCode:

BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.DotCode, "PARTID: A1234B5");

Step 3: Customize DotCode Settings

Configure size, rows, columns, or style as needed:

// Set module (pixel) size
generator.Parameters.Barcode.XDimension.Pixels = 6;
// Optional: Set number of rows and columns
generator.Parameters.Barcode.DotCode.DotCodeRows = 12;
generator.Parameters.Barcode.DotCode.DotCodeColumns = 10;
// Optional: Set foreground and background color
generator.Parameters.Barcode.BarColor = Color.Black;
generator.Parameters.Barcode.BackColor = Color.White;

Step 4: Generate and Save the DotCode Barcode

Export the barcode to PNG, JPEG, or any supported format:

generator.Save("dotcode-part.png", BarCodeImageFormat.Png);

Step 5: Complete Example

using Aspose.BarCode.Generation;
using System.Drawing; // Required for Color

class Program
{
    static void Main()
    {
        // Create DotCode generator for a part ID
        BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.DotCode, "PARTID: A1234B5");
        generator.Parameters.Barcode.XDimension.Pixels = 6;
        generator.Parameters.Barcode.DotCode.DotCodeRows = 12;
        generator.Parameters.Barcode.DotCode.DotCodeColumns = 10;
        generator.Parameters.Barcode.BarColor = Color.Black;
        generator.Parameters.Barcode.BackColor = Color.White;
        generator.Save("dotcode-part.png", BarCodeImageFormat.Png);
        // Test output with industrial DotCode scanners
    }
} 

Use Cases and Applications

  • Direct part marking: Automotive, aerospace, or electronics components
  • Industrial automation: High-speed conveyor labeling
  • Logistics: Robust codes for packages or parcels

Common Challenges and Solutions

Challenge 1: DotCode not readable? Solution: Test with industry scanners, use clear colors and correct module size for the application.

Challenge 2: Image size or layout issues? Solution: Adjust rows/columns, XDimension, and export resolution for the best fit.

Challenge 3: Data too long? Solution: Shorten code text or increase grid size (more rows/columns).


Performance Considerations

  • Tune rows and columns to match data and surface area
  • Batch generate DotCode barcodes for automation workflows
  • Use memory streams for in-memory barcode export

Best Practices

  1. Choose module size and grid to fit your application’s space
  2. Test DotCode on curved, rough, or direct-marked surfaces
  3. Use high-contrast colors for reliable machine reading
  4. Document code text and settings for traceability

Advanced Scenarios

1. Batch Generate DotCode Barcodes

foreach (var part in parts)
{
    BarcodeGenerator g = new BarcodeGenerator(EncodeTypes.DotCode, part.CodeText);
    g.Save($"dotcode_{part.Id}.png", BarCodeImageFormat.Png);
}

2. Set DotCode Row and Column Sizes

generator.Parameters.Barcode.DotCode.DotCodeRows = 20;
generator.Parameters.Barcode.DotCode.DotCodeColumns = 16;

Conclusion

With Aspose.BarCode for .NET, you can generate DotCode barcodes for industrial and logistics use—ideal for direct part marking and high-volume environments. Find more info in the Aspose.BarCode API Reference .

 English