2

I use ZXing 3.2 java lib and I need to generate a rectangular data matrix 16 * 48 cells (16 cells for height and 48 cells for width).

I found no way for do this. Does anyone know how to do this?

Snippet example:

Hashtable<EncodeHintType,Object> hints=null;
hints=new Hashtable<EncodeHintType,Object>(1);
hints.put(EncodeHintType.DATA_MATRIX_SHAPE,SymbolShapeHint.FORCE_RECTANGLE);

MultiFormatWriter writer = new MultiFormatWriter();
BitMatrix         result = writer.encode("50 digits",format,48,16,hints);

The result is data matrix with 16 cells for Height and 35 for Weight. Changing the width in encode function has no effect in the result. The height is always set to 16 cells.

Thank you for your time

Muralex
  • 21
  • 2

1 Answers1

0

One way is to pad the data with spaces to the required length (e.g. 70 characters give a nice 16*48 pattern).

However this will result in minimal error correction because all available space will be filled with data.

A better way is to enforce MIN_SIZE and MAX_SIZE as these are not deprecated for Data Matrix:

hints.put(EncodeHintType.MIN_SIZE, new Dimension(48, 16));
hints.put(EncodeHintType.MAX_SIZE, new Dimension(48, 16));
GSerg
  • 76,472
  • 17
  • 159
  • 346