Ask Your Question
2

How can one create a GS1 DataMatrix using ZXing.Net?

asked 2023-06-27 21:23:13 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-06-27 21:40:01 +0000

djk gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-27 21:23:13 +0000

Seen: 15 times

Last updated: Jun 27 '23