Search code examples
c#barcode-scannerzxing.net

Can ZXing can read multiple barcode in the single image using C#?


I am trying to read multiple barcodes in a jpg image using the ZXing library. But it's returning only one barcode. I am not getting any source on how I can modify my code so that it read multiple barcodes. My code is:

private string readPDFBarcode(String fname) {
            
            IBarcodeReader reader = new BarcodeReader()
            {
                AutoRotate = true,
                TryInverted = true,
                Options = new DecodingOptions
                {
                    TryHarder = true,
                    PureBarcode = false,
                    ReturnCodabarStartEnd = true,
                    PossibleFormats = new List<BarcodeFormat> { BarcodeFormat.CODE_128, BarcodeFormat.CODE_39, BarcodeFormat.UPC_E }
                }
            };
            
            Bitmap oBitmap = new Bitmap(fname);
            var result = reader.Decode(oBitmap);
            if (result != null)
            {
                return result.ToString();
            }
            else {
                return "";
            }
        }

Any suggestions will be of great help. Thank you!


Solution

  • Try this one:

    var results = reader.DecodeMultiple(oBitmap);
    

    If it isn't available in your environment, please give some information about the target .net framework (classic or core).