Java Barcode Reader Developer Guide

How to scan, read linear, 2d barcode images in Java web application

How to Scan & Read Linear & 2D BarCodes in Java applications using Java Barcode Reader Library



Java Barcode Reader is a Java barcode scanning library which scan and read 1D (linear) and 2D (matrix) barcodes from image files. Besides Java Barcode Reader library, OnBarcode also provides Java Barcode Generator for generating linear and 2D barcodes in the Java program.

This article provides detailed developer guide for Java Barcode Reader library. To use this article, you need first download the trial version of Java Barcode Reader from our site.


Index
 

Java Barcode Reader Package Overview

  • OnBarcode.BarcodeReader.jar library for Barcode Reader

  • test-src contains testing application, its souce codes and sample images.

  • lib contains two jars for TIFF and bitmap image.

  • Purchase-Java-Barcode-Reader.html contains link to buy OnBarcode.com Java Barcode Reader online.

  • DeveloperGuide.html developer guide.
 

Java Barcode Reader Install & Requirement

Requirement

You need Java JDK 1.4.2 or later version.

Install

Put BarcodeReader.jar into your Java project classpath.

To read Tiff and bitmap image, you need two extra jars from Sun Microsystem, see how to read barcodes from tiff and bitmap images.

 

How to read barcodes using Java Barcode Reader?

Read barcodes from image is a simple task with barcode reader for java library.

Here is the sample code.

           String[] datas = BarcodeReader.read(new File("C:/YourBarcodeImage.gif"), BarcodeReader.EAN8);

Pass your barcode image file, and barcode type to BarcodeReader, and it will return barcode datas. Complete demo source code is under test-src folder.

 

Java Barcode Reader FAQ




How to read barcode from a specified area (rectangle) in the image?

To improve scanning speed, you can specify a rectangle area in the image for scanning barcode.

ScanOption option = new ScanOption();
/**
* specify barcode area in the scanning image
*
* x1, y1, x2, y2, valid values are from 0 to 1, inclusive.
*
* @param x1  barcode area left top point X value, % of image width
* @param y1  barcode area left top point Y value, % of image height
* @param x2  barcode area right bottom point X value, % of image width
* @param y2  barcode area right bottom point Y value, % of image height
*/
// scan top 20% of the image
option.setScanDirection(ScanOption.SCAN_FROM_TOP_TO_BOTTOM);
option.setBarcodeArea(0, 0, 1, 0.2);
String[] datas = BarcodeReader.read(new File("C:/YourBarcodeImage.gif"), BarcodeReader.EAN8, option);
  • Pass your barcode image file, and barcode type, and ScanOption object to BarcodeReader, and it will return barcode datas in the specified area from the image.




TIFF/Bitmap Image Reader


For TIFF or Bitmap image reading only, developers need include two Java Advanced Imaging jars from Sun Microsystems, jai_codec.jar, jai_core.jar. Both are included under lib folder.
To know more details about Java Advanced Imaging, please go to Java Advanced Imageing Site.




How to get supplement barcode data?



For barcode EAN 8, EAN 13, UPC-A, UPC-E, their barcode image may contain 2 or 5 digits supplement barcode, Java Barcode Reader will add supplement barcode data to the main barcode data.

For example, Java barcode reader will return data as "123450512345" for above sample image. The First 7 digits "1234505" is UPCE data, and the last 5 digits "12345" is UPCE supplement data.




About UPC-E data



For UPC-E barcode, usually there are 8 digits printed on the barcode label. The first digit is UPC-E number system, valid values are 0 or 1. The next 6 digits are UPC-E data, and the last one is checksum.

Our library will return 6 digits data and the last one checksum. Developer should use the first 6 digits as UPC-E data, according to UPC-E specification.

For the above barcode image, 0 is the number system, 123450 is the UPC-E data, and 5 is the checksum. Our library will return 1234505, plus suppliment barcode 12345. So the final output will be 123450512345.




Support Multi-page Tiff File



For multi-page tiff file, Java barcode reader will scan every page in the file, and return all barcodes in all pages.




Java Barcode Reader Supporting Bar Code Symbology Types





OnBarcode is a market-leading provider of barcode imaging generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides comprehensive tutorials and how-tos for various linear, 2d barcode information, such as C# in ASP.NET, C# .NET, C# Barcode Encoding, C# Barcode Image, VB.NET in ASP.NET, VB.NET Winforms, VB.NET Barcode Encoding. OnBarcode barcode products are supported by RasterEdge ASP.NET Document Viewer, which supports ASP.NET PDF Viewer, ASP.NET MVC Document Viewer, ASP.NET PDF Editor, MVC PDF Viewer. And provide high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.