Generating GS1 DataMatrix using ZXing.Net

那年仲夏 提交于 2019-12-06 14:37:54

问题


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:

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

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:

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.


回答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, ...).



来源:https://stackoverflow.com/questions/43539564/generating-gs1-datamatrix-using-zxing-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!