ZXing not reading Brazilian Barcode bills (interleaved 2 of 5) correctly. How can I fix it?

StackOverflow https://stackoverflow.com/questions/22234424

  •  10-06-2023
  •  | 
  •  

Question

I am using XZing 2.3.0 for reading ITF barcodes, but ZXing doesn't read correctly Brazilian Bills with 47 digits.

The following sample barcode image (available here) is been read as 033915959002000008009557735480001438148929501028 instead of 03399557345480001431548929501020159590000000800.

A sample PDF (for printing) is available here. The barcode sequence number is on the top of the bill (a long sequence of numbers separeted by point and space).

I already tried the following code (but with no success):

Intent intent = new Intent("com.google.zxing.client.android.SCAN"); intent.putExtra("SCAN_FORMATS", "AZTEC,CODABAR,CODE_39,CODE_93,CODE_128,DATA_MATRIX,EAN_8,EAN_13,ITF,MAXICODE,PDF_417,QR_CODE,RSS_14,RSS_EXPANDED,UPC_A,UPC_E,UPC_EAN_EXTENSION"); intent.putExtra("SCAN_MODE", Intents.Scan.ONE_D_MODE); intent.putExtra("ALLOWED_LENGTHS", new int[] { 48, 44, 47, 24, 20, 18, 16, 14, 12, 10, 8, 6 });

How can I make ZXing read that barcode correctly?

Thanks for your help guys, and let me know if I can clarify anything else.

Was it helpful?

Solution 2

Resolved! ZXing is reading right. The problem is the brazilian pattern, because the fields are disposed in a different order from the displayed at the top of the bill. That's crazy!

OTHER TIPS

As @Michael says, you aren't actually sure the barcode says what you think it does.

The barcode does say 03391595900000008009557354800014314892950102

http://zxing.org/w/decode?u=http%3A%2F%2Fwww.shimatai.com.br%2Fimages%2Fboleto.png

http://online-barcode-reader.inliteresearch.com/default.aspx 03391595900000008009557354800014314892950102

http://online-barcode-reader.com/ 03391595900000008009557354800014314892950102

so, here go some tips about Brazilian barcodes for 'boletos'.

First of all, they use a type of barcode called 'interleaved 2 of 5'. This type usually requires that you set the sizes on the barcode scanner (for instance: to read 44 length barcodes). This is because this type allow 'half-reading' (when you read only part of the code) so fixing a size is a turn around.

The second thing is that what bank expects is a code called IPTE, which is in a different layout than the code in the bars.

To make things worst, IPTE is standardized but the barcodes isn't. So despite of being of the same type and the same lenght, each bank use a different layout. you could have for instance the bank account in the middle or in the end of the code. Only the beginning of the code is standardized and refers to the bank number. From there, each bank developed the rest of the code their way.

You could try to use BoletoNet which incorporates the logics of barcodes into your system or read documentation at Febraban site (Febraban is the Brazilian Banks Association). Both sites and documentations are avaiable only in Portuguese.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top