wood burning stoves 2.0*
The moose likes Blatant Advertising and the fly likes How to Read Barcode from Multi-page TIFF Images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Blatant Advertising
Bookmark "How to Read Barcode from Multi-page TIFF Images" Watch "How to Read Barcode from Multi-page TIFF Images" New topic

How to Read Barcode from Multi-page TIFF Images

sherazam khan
Ranch Hand

Joined: Mar 10, 2010
Posts: 279
This technical tip shows how to Read Barcode from Multi-page TIFF Images using Aspose.BarCode for Java. Please make sure to install JRE 1.5 or above to run and JDK 1.5 or above for development. Then Download Aspose.BarCode for Java, install it as well.  Below is the sample code for recognizing barcodes with in a multi-page tiff image.


import com.aspose.barcode.*;

import com.sun.media.jai.codec.ImageCodec;

import com.sun.media.jai.codec.ImageDecoder;

import com.sun.media.jai.codec.TIFFDecodeParam;

import javax.imageio.ImageReader;

import javax.imageio.stream.ImageInputStream;

import java.awt.image.BufferedImage;

import java.io.File;

import java.io.IOException;

import java.util.Iterator;


* Read barcodes from multi-pages tiff image sample

* Integreted Sun's JAI (Java Advanced Imaging) Library to working with tiff files

* Details information about JAI: http://java.sun.com/javase/technologies/desktop/media/


public class TiffWithJAI {

    public static void main(String[] args) throws Exception {

                String fileName = "C:\\multi_page.tiff";

        Iterator readers = javax.imageio.ImageIO.getImageReadersBySuffix("tiff");

        if (readers.hasNext()) {

            File fi = new File(fileName);

            ImageInputStream iis = javax.imageio.ImageIO.createImageInputStream(fi);

            TIFFDecodeParam param = null;

            ImageDecoder dec = ImageCodec.createImageDecoder("tiff", fi, param);

            //Get the page count of the tiff image

            int pageCount = dec.getNumPages();

            ImageReader _imageReader = (ImageReader) (readers.next());

            if (_imageReader != null) {

                _imageReader.setInput(iis, true);

                //Feed each page to the BarCodeReader

                for (int i = 0; i < pageCount; i++) {

                    BufferedImage _bufferedImage = _imageReader.read(i);

                    com.BarCodeReader reader = new BarCodeReader(_bufferedImage, BarCodeReadType.Datamatrix);

                    //Read the barcodes in a single page

                    while (reader.read())









More about Aspose.BarCode for Java

- Homepage of Aspose.BarCode for Java

- Read more Technical Tips by Aspose.BarCode

- Download of Aspose.BarCode for Java

Contact Information

Aspose Pty Ltd

Suite 163, 79 Longueville Road

Lane Cove, NSW, 2066


Aspose - The .NET and Java component


Phone: 888.277.6734

Fax: 866.810.94651

It is sorta covered in the JavaRanch Style Guide.
subject: How to Read Barcode from Multi-page TIFF Images
Similar Threads
Sample Mobile Device App. to Generate & Display Barcode Image
Generate & Recognize Barcodes from PDF Documents in Java Applications
Insert PDF Bookmarks While Converting a Spreadsheet to PDF file
Access & Read Embedded Email Attachments From Existing Email Message
Convert Email Messages to MHTML, MSG & EML Using Aspose.Email Java API