forcing square data matrix codes using ZXing.Net?

897 views Asked by At

I was wondering if there was a way to ensure that a data matrix code created with ZXing.Net comes out as a square?

I'm not talking about the the image itself but the code itself.

I have code that generates images with data matrix codes from input texts and in some cases it is a square code (the code not the image) and in other cases it is more like a flat rectangle (the code, not the image).

So is the flat rectangular code just how the code looks due to the input or can it in fact be forced into a square?

1

There are 1 answers

0
Michael On

You can try the following snippet:

var writer = new BarcodeWriter
{
   Format = BarcodeFormat.DATA_MATRIX,
   Options = new DatamatrixEncodingOptions
   {
      SymbolShape = SymbolShapeHint.FORCE_SQUARE
   }
};
var image = writer.Write("<your content here>");