VintaSoft Barcode .NET SDK v10.0
How to read GS1-128 barcode?

Example: Here is an example that shows how to detect GS1-128 barcode in an image and parse barcode data stored in GS1 format.

Public Shared Sub Recognize(image As Image)
        ' create the barcode reader
        Using reader As New BarcodeReader()
                ' specify that reader must search for GS1-128 barcodes only

                reader.Settings.ScanBarcodeTypes = BarcodeType.None
                reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.GS1_128)

                ' recognize barcode on image
                Dim infos As IBarcodeInfo() = reader.ReadBarcodes(image)

                ' for each found barcode
                For j As Integer = 0 To infos.Length - 1
                        Dim info As GS1BarcodeInfo = DirectCast(infos(j), GS1BarcodeInfo)

                        ' print barcode symbology
                        Console.WriteLine(info.BarcodeSubset)

                        ' print barcode region on image
                        Console.WriteLine(info.Region.ToString())

                        ' print Transmitted data
                        Console.WriteLine(String.Format("Transmitted data            : {0} ", info.TransmittedData))

                        ' print Application identifiers values
                        Dim printableValue As New StringBuilder()
                        Dim aiValues As GS1ApplicationIdentifierValue() = info.ApplicationIdentifierValues
                        For i As Integer = 0 To aiValues.Length - 1
                                Dim aiValue As GS1ApplicationIdentifierValue = aiValues(i)
                                Dim ai As GS1ApplicationIdentifier = aiValue.ApplicationIdentifier
                                Console.WriteLine(String.Format("Application identifier {0}    : {1}", i + 1, ai.ApplicationIdentifier))
                                Console.WriteLine(String.Format("  Value                     : {0}", aiValue.Value))
                                Console.WriteLine(String.Format("  Data title                : {0}", ai.DataTitle))
                                Console.WriteLine(String.Format("  Data content              : {0}", ai.DataContent))
                                Console.WriteLine(String.Format("  Format                    : {0}", ai.Format))
                                Console.WriteLine(String.Format("  Is contains decimal point : {0}", ai.IsContainsDecimalPoint))
                                Console.WriteLine(String.Format("  Is variable length        : {0}", ai.IsVariableLength))
                                printableValue.Append(aiValue.ToString())
                        Next

                        ' print GS1 printable value
                        Console.WriteLine("Printable GS1 value: " & printableValue.ToString())
                        Console.WriteLine()
                Next
        End Using
End Sub
              
public static void Recognize(Image image)
{
    // create the barcode reader
    using (BarcodeReader reader = new BarcodeReader())
    {
        // specify that reader must search for GS1-128 barcodes only

        reader.Settings.ScanBarcodeTypes = BarcodeType.None;
        reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.GS1_128);

        // recognize barcode on image
        IBarcodeInfo[] infos = reader.ReadBarcodes(image);

        // for each found barcode
        for (int j = 0; j < infos.Length; j++)
        {
            GS1BarcodeInfo info = (GS1BarcodeInfo)infos[j];

            // print barcode symbology
            Console.WriteLine(info.BarcodeSubset);

            // print barcode region on image
            Console.WriteLine(info.Region.ToString());

            // print Transmitted data
            Console.WriteLine(string.Format("Transmitted data            : {0} ", info.TransmittedData));

            // print Application identifiers values
            StringBuilder printableValue = new StringBuilder();
            GS1ApplicationIdentifierValue[] aiValues = info.ApplicationIdentifierValues;
            for (int i = 0; i < aiValues.Length; i++)
            {
                GS1ApplicationIdentifierValue aiValue = aiValues[i];
                GS1ApplicationIdentifier ai = aiValue.ApplicationIdentifier;
                Console.WriteLine(string.Format("Application identifier {0}    : {1}", i + 1, ai.ApplicationIdentifier));
                Console.WriteLine(string.Format("  Value                     : {0}", aiValue.Value));
                Console.WriteLine(string.Format("  Data title                : {0}", ai.DataTitle));
                Console.WriteLine(string.Format("  Data content              : {0}", ai.DataContent));
                Console.WriteLine(string.Format("  Format                    : {0}", ai.Format));
                Console.WriteLine(string.Format("  Is contains decimal point : {0}", ai.IsContainsDecimalPoint));
                Console.WriteLine(string.Format("  Is variable length        : {0}", ai.IsVariableLength));
                printableValue.Append(aiValue.ToString());
            }

            // print GS1 printable value
            Console.WriteLine("Printable GS1 value: " + printableValue.ToString());
            Console.WriteLine();
        }
    }
}