1

What I need

Is to generate a working GS1 DataMatrix, using this test content:

(240)1234567890(10)AA12345(11)123456(21)1(96)1234567

Steps

I've downloaded the nuget package from here:

enter image description here

and

I've created a console app that uses this code:

private static void DoGs1DataMatrixStuff()
{
    var writer = new BarcodeWriter
    {
        Format = BarcodeFormat.DATA_MATRIX
    };

    writer
        .Write("(240)1234567890(10)AA12345(11)123456(21)1(96)1234567")
        .Save(@"C:\Temp\barcode.png");
}

There's no obvious specific GS1_DataMatrix format I can use ...

that gives me

enter image description here

which if read by a scanner app on my smartphone, gives the literal content that I originally presented, not with the FNC1 formatting that I expect for GS1:

(240)1234567890(10)AA12345(11)123456(21)1(96)1234567

while it should be

2401234567890 10AA12345 11123456211 961234567

From another source (not a source I can use) I got this barcode:

enter image description here

Using my smartphone app this reads into the correct data.

Question

How can I recreate this working GS1 datamatrix, using ZXing.Net?

also see

this link, Chris Bahns raises the same concern I have, but his request didn't get a working answer.

Terry Burton
  • 2,801
  • 1
  • 29
  • 41
Spikee
  • 3,967
  • 7
  • 35
  • 68

1 Answers1

1

You have to use a formatted string with ASCII character 29 (GS - Group Separator):

< GS >2401234567890< GS >10AA12345< GS >11123456211< GS >961234567

(replace the "< GS >" with ASCII 29)

ZXing.Net supports the GS symbol with the ASCII encoder since version 0.15. It replaces the ASCII 29 value with the FNC1 codeword (232) in the resulting datamatrix image.

That's only a low level support. There is no built in class or something similar which understands AI (application identifiers) with fixed or variable length (similar to the result parser classes for vCards, vEvent, ISBN, ...).

Michael
  • 2,361
  • 1
  • 15
  • 15
  • So that's this one: `↨`? That results in `Message contains characters outside iso-8859-1 encoding.`. – Spikee Apr 24 '17 at 05:51
  • It's got to do with the `BarcodeFormat.DATA_MATRIX`, if I switch that to `QR_CODE` there's no such error, but then ofcourse the data isn't good because `↨` is displayed as `?` (QR_CODE can't handle it). – Spikee Apr 24 '17 at 12:27
  • No, it's not that character. The ASCII 29 isn't printable. For example you can encode such a string with the following code snippet `writer .Write((char)29 + "2401234567890" + (char)29 + "10AA12345" + (char)29 + "11123456" + (char)29 + "211" + (char)29 + "961234567");` Not every `(char)29` is needed if application identifiers with fixed data lengths are used. – Michael Apr 24 '17 at 20:03
  • And GS1 with QR Code isn't supported with zxing. – Michael Apr 24 '17 at 20:07