0

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!

Piyush
  • 492
  • 5
  • 22
  • Does this answer your question? [Can ZXing.NET read multiple QR barcodes in same image?](https://stackoverflow.com/questions/27129312/can-zxing-net-read-multiple-qr-barcodes-in-same-image) – Martheen Mar 26 '21 at 09:43
  • No, That is for QRCode and I am looking to read multiple barcode . – Piyush Mar 26 '21 at 09:59
  • DecodeMultiple works whether you're dealing with QR or barcode – Martheen Mar 26 '21 at 10:02
  • Can you do this in your application by splitting one image into multiple images, each containing what appears to be a barcode, and using each to call ZXing? – kunif Mar 26 '21 at 12:17
  • For example, this [Japanese article](http://d.sunnyone.org/2015/09/zxingnet.html) and these [Java article](https://stackoverflow.com/q/60377223/9014308) and [Linked article](https://stackoverflow.com/q/60389632/9014308) may be helpful. – kunif Mar 26 '21 at 22:37

1 Answers1

3

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).

Michael
  • 2,361
  • 1
  • 15
  • 15