0

What properties need to be set on an itextsharp Data-Matrix barcode to enable me to pass UTF-8 chars into the content?

var matrix = new BarcodeDatamatrix();
iTextSharp.text.Image img = null;

//matrix.Options = BarcodeDatamatrix.DM_ASCII;
matrix.Options = BarcodeDatamatrix.DM_AUTO;
//matrix.Options = BarcodeDatamatrix.DM_B256;
//matrix.Options = BarcodeDatamatrix.DM_TEXT;

matrix.Generate("!\"#$%&\'()*+,-./:;< => ?@[\\]^_`{|}~¡¢£¤¥¦§¨©ª«¬ ®¯°±²³´µ¶·¸¹º»¼½¾¿0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ");

img = matrix.CreateImage();

This c# code creates the barcode, but the contents are invalid. I've tried the other listed matrix.Options too.

Mark Cooper
  • 6,738
  • 5
  • 54
  • 92
  • 1
    Can you share the barcode image that is produced? I generated a barcode in Java without any options and it does produce correct result (according to [this](https://online-barcode-reader.inliteresearch.com/) online barcode reader) – Alexey Subach Mar 22 '17 at 19:50
  • I'm using iTextSharp to create the barcode, and I believe that this is where the problem lies. – Mark Cooper Mar 23 '17 at 08:15
  • I tried with iTextSharp and got the same correct result, so I believe the problem is not in the software. – Alexey Subach Mar 23 '17 at 09:07
  • @AlexeySubach the problem was with the scanner I was using, not the code. Changed to a different scanner and all seems fine! FYI I'm using a barcode scanner on Android. "Barcode Scanner v4.3" works OK, but "QR Scanner v0.33" did not. Thanks for your help. – Mark Cooper Mar 24 '17 at 11:03
  • Look how simple it was! You could just use the link I gave you in the first place and save yourself a day :) – Alexey Subach Mar 24 '17 at 11:04

1 Answers1

0

The problem was with the scanner I was using and not the code.

@AlexeySubach posted an example of an online scanner that works. I was using a scanner on Android that did not work.

In the end I have switched apps to Barcode Scanner by Zxing and this is now working well.

(I have no affiliation to this app nor the developers)

Mark Cooper
  • 6,738
  • 5
  • 54
  • 92