micjahn / ZXing.Net

.Net port of the original java-based barcode reader and generator library zxing
Apache License 2.0
2.7k stars 668 forks source link

Data Matrix Whether to support gs1 standard #111

Closed MarkLogZhu closed 6 years ago

MarkLogZhu commented 6 years ago

Data Matrix Whether to support gs1 standard,If it is supported, what to do? Here is my code: public Bitmap getDataMatrix(string inputData, int barcodeWidth, int barcodeHeight) {

DatamatrixEncodingOptions options = new DatamatrixEncodingOptions() {
    Width = barcodeWidth,//宽度
    Height = barcodeHeight,//高度                
    Margin = 0,
    PureBarcode = true,

    SymbolShape = SymbolShapeHint.FORCE_SQUARE
};
//
options.Hints.Add(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
//options.Hints.Add(EncodeHintType.MARGIN, 1);
BarcodeWriter writer = new BarcodeWriter() {
    Format = BarcodeFormat.DATA_MATRIX,
    Options = options
};
var img = writer.Write(inputData);

return img;

}

micjahn commented 6 years ago

Please take a look into the wiki: https://github.com/micjahn/ZXing.Net/wiki/Generating-GS1-DataMatrix-and-GS1-Code128-barcodes

MarkLogZhu commented 6 years ago

Thank you very much for your prompt reply。If it is dynamic data When does the second separators need to be added?

micjahn commented 6 years ago

I strongly recommend reading the official specifications for GS1 barcodes: https://www.gs1.org/barcodes/2d There is everything explained which is important for the GS1 standard.