Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To create a GS1 DataMatrix using ZXing.Net, you need to follow these steps:

  1. Install ZXing.Net NuGet package in your project.
  2. Create a BarcodeWriter object with the DataMatrix format.
  3. Set properties of the BarcodeWriter object to specify the GS1 encoding format and other options.
  4. Generate a GS1 encoded data string for your data.
  5. Create a BitMatrix object with the encoded data string and the width and height of the DataMatrix.
  6. Convert the BitMatrix to a Bitmap image using the ZXing.Net barcode writer.

Here is a sample code that creates a GS1 DataMatrix using ZXing.Net:

using ZXing;
using ZXing.Datamatrix;
using ZXing.Common;

// Create a DataMatrix writer with GS1 encoding
var barcodeWriter = new BarcodeWriter
{
    Format = BarcodeFormat.DATAMATRIX,
    Options = new DatamatrixEncodingOptions
    {
        GS1Format = true,
        ModuleSize = 5,
        SymbolShape = SymbolShapeHint.FORCE_SQUARE
    }
};

// Generate a GS1 encoded data string for your data
var gs1Data = "(01)00012345678901234(17)141231";

// Create a BitMatrix with the encoded data and size options
var bitMatrix = barcodeWriter.Encode(gs1Data, BarcodeFormat.DATAMATRIX, 0, 0);

// Convert the BitMatrix to a Bitmap image
var bitmap = barcodeWriter.Write(bitMatrix);

Note: Make sure to adjust the GS1 data string and the size options according to your requirements.