Jump to content

Reading Bar Codes with zxing Java Library


Bob Minteer
 Share

This topic is 2907 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Has anyone had success using the zxing library to read/decode bar codes with ScriptMaster ?   I generate them just fine using the Barcode4J library.

 

I think I am having dependency issues (take a pill...) and not much forward momentum getting it to work.

 

Examples, suggestions or commiseration are greatly accepted.  

 

regards...

 

Bob Minteer

 

Link to comment
Share on other sites

Bob

this works for QR codes definitely and most of the other supported types at https://github.com/zxing/zxing/, I think I have other bit of code too... just needs the javase-nn.jar and the code-nn.jar

I am using 2.3 with Java  6 at the moment

 

I pass is the name of a container field in the table I run this in as fm_container

import com.google.zxing.*
import com.google.zxing.client.j2se.*
import com.google.zxing.common.*
import javax.imageio.ImageIO

barCodeInputStream = fmpro.getContainerStream (fm_container)
barCodeBufferedImage = ImageIO.read(barCodeInputStream)

LuminanceSource source = new BufferedImageLuminanceSource(barCodeBufferedImage)
bitmap = new BinaryBitmap(new HybridBinarizer(source)) 
reader = new MultiFormatReader()
try {
	result = reader.decode(bitmap)  
} catch ( Exception e) {
	return e
}
return result.getText()
  • Like 1
Link to comment
Share on other sites

Many thanks John!  

 

That has put me back on track.   

 

I am attempting to read barcodes from PDF's.

 

While working through this, I kept testing and tweaking... to no avail.     

 

Then it occured to me, "Doh!  I have to convert the PDF's to images like tiff before zxing will do the decoding".

 

Your code works great on images with EAN128, Code39 and QR.

 

Now I am on to working out conversion via the Apache PDFBox library so that I am passing an image to zxing library.

 

regards...

 

Bob Minteer

Link to comment
Share on other sites

This topic is 2907 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.