Search code examples
javabarcodezxingbarcode-scannercode128

Zxing NotFoundException with Barcode 128C


I try to use Zxing to decode 128C (Code set C) barcodes. I have success when I read other types like QR_CODE, UPC_A.

These are barcodes that I trying to read:

enter image description here

enter image description here

Is possible read 128C barcodes (Not CODE 128 pure) with Zxing ?


Solution

  • Short aswer, yes, it should is possible. As 128C just is a subset of 128. Can scan the codes, might take a few seconds. And have XZing working in a app.

    You have found out that 128 is supported, now you got to make an translation. 128C takes the same input as 128, just turns out numbers. So you could make a translation from the data you get back, and turn it into 128C. Check the second link for how that translates.

    https://github.com/zxing/zxing/blob/master/README.md

    https://en.wikipedia.org/wiki/Code_128

    Get the needed classes from the XZing github, put them in a package in the java part of your project. I used only 2:

    • IntentIntegrator
    • IntentResult

    Here is how it is initiated in my code:

    /**
    * Method called to intiate the scan (it's linked to a button)
    */
    public void doScan(View view) {
        IntentIntegrator scanIntegrator = new IntentIntegrator(this);
        scanIntegrator.initiateScan();
    }
    
    // when you click the Scan Bar Code button
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
    
        if (scanningResult != null) { // we have a result
    
    
               String scanContent = scanningResult.getContents(); // set the content of the scan.
               String scanFormat = scanningResult.getFormatName(); // set the type of scan.
    
               // You will want to put this data somewhere else, globals, etc.
    
            } else {
                toast("No scan data received!"); // call to make a toast
            }
        }