Link Search Menu Expand Document

Decode EAN-2 - C#

BarCode Reader SDK sample in C# demonstrating ‘Decode EAN-2’

using System;
using System.IO;
using Bytescout.BarCodeReader;

namespace ReadEAN2
    class Program
        const string ImageFile = "EAN2.png";

        static void Main()
            Console.WriteLine("Reading barcode(s) from image {0}", Path.GetFullPath(ImageFile));

            Reader reader = new Reader();
            reader.RegistrationName = "demo";
			reader.RegistrationKey = "demo";

            // Set barcode type to find
            reader.BarcodeTypesToFind.EAN2 = true;
            // EAN-2 barcode is normally supplemental to EAN-13 so we should force the detection of standalone EAN-2 barcode.
            reader.AllowOrphanedSupplementals = true;
            /* -----------------------------------------------------------------------
            NOTE: We can read barcodes from specific page to increase performance.
            For sample please refer to "Decoding barcodes from PDF by pages" program.
            ----------------------------------------------------------------------- */

            // Read barcodes
            FoundBarcode[] barcodes = reader.ReadFrom(ImageFile);

            foreach (FoundBarcode barcode in barcodes)
                Console.WriteLine("Found barcode with type '{0}' and value '{1}'", barcode.Type, barcode.Value);

			// Cleanup
            Console.WriteLine("Press any key to exit..");

Download Source Code (.zip)

Return to the previous page Explore BarCode Reader SDK

Copyright © 2016 - 2023 ByteScout