We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Receiving ArrayIndexOutOfBoundsException

Hi there,

The latest version 5.4.0 of the Java version fixes the problem of it getting slower and slower which is great.

I have a different issue now though:

To alleviate some of the problems of it taking a while to scan a full page (10 seconds at 200dpi) I take sections of the page where the barcodes are more likely to be and process those parts first.

It seems that some sizes of tif cause the component to except with an ArrayIndexOutOfBounds error.

I have attached a tif file which causes this to happen.

I get this call stack:
java.lang.ArrayIndexOutOfBoundsException: 122780
at com.aspose.barcoderecognition.br.a(Unknown Source)
at com.aspose.barcoderecognition.br.a(Unknown Source)
at com.aspose.barcoderecognition.bY.b(Unknown Source)
at com.aspose.barcoderecognition.bY.a(Unknown Source)
at com.aspose.barcoderecognition.p.B(Unknown Source)
at com.aspose.barcoderecognition.p.l(Unknown Source)
at com.aspose.barcoderecognition.BarCodeReader.read(Unknown Source)
I hope you can find and fix this problem.


Hi Erik,

Thanks for your inquiry. I tested your sample bar code image against the latest build of Aspose.BarCode for Java 5.4.0. I’m unable to reproduce the error message on my side. Could you please share the environment details where it fails i.e. Operating System, IDE (Eclipse, Netbeans etc), JDK version. We’ll investigate the issue at our end and guide you accordingly. This will help us to replicate the problem on our side.

BarCodeReader reader = <span style=“font-size:10.0pt;font-family:“Courier New”;color:#7F0055”>new BarCodeReader(<span style=“font-size:10.0pt;font-family:“Courier New”;color:#2A00FF”>“C:/temp/Error.tif”,
<span style=“font-size:10.0pt;font-family:“Courier New”;



System.out.println("Code :" + reader.getCodeText());



Code :0317666597

Hi Imran,

It works fine when reading the tif file directly, but not when it’s coming from a BufferedImage.

Here is some example code that reproduces the problem:

* Converts the supplied image into an {@link InputStream}
* @param image The {@link BufferedImage} convert
* @return {@link InputStream} of the supplied image
* @throws IOException
private InputStream getImageInputStream(BufferedImage image) throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
	ImageIO.write(image, "tiff", os);

	return new ByteArrayInputStream(os.toByteArray());

 * Returns a list of BufferedImages, one for each page of the supplied tiff file
 * @param inFile The tiff file to process
 * @return List<bufferedimage>
 * @throws IOException
private List<bufferedimage> getTiffPages(File inFile) throws IOException {
	List<bufferedimage> result = new ArrayList<bufferedimage>();
	Iterator<imagereader> readers = javax.imageio.ImageIO.getImageReadersBySuffix("tiff");
	if (readers.hasNext()) {
		ImageInputStream iis = javax.imageio.ImageIO.createImageInputStream(inFile);
		TIFFDecodeParam param = null;
		ImageDecoder dec = ImageCodec.createImageDecoder("tiff", inFile, 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 List of Buffered Images to return
			for (int i = 0; i < pageCount; i++) {
	return result;

public void testScan() {
	List<bufferedimage> images;
	try {
		images = getTiffPages(new File("C:/temp/Error.tif"));
		for (int i = 0; i < images.size(); i++) {
			BarCodeReader reader = new BarCodeReader(getImageInputStream(images.get(i)), BarCodeReadType.Code128);

			if (reader.read()) {
				System.out.println("Code :" + reader.getCodeText());
	} catch (IOException e) {
}</bufferedimage></imagereader></bufferedimage></bufferedimage></bufferedimage></bufferedimage></pre><div>I am using Windows 7 with Eclipse Juno and Java 7</div><div><br></div><div>Thanks!</div>

Hi Erik,

Thank you for sharing the sample source code. I managed to replicate the exception message. This problem has been logged in our bug tracking system under ticket Id BARCODJAVA-33325. We will soon investigate the cause. Also, you will be notified once the fix for your problem is available for public use.

Please accept our apologies for your inconvenience.

Hi Erik,

Thanks for your patience. Good news for you is BARCODJAVA-33325 has now been resolved and its fix will be included in the upcoming hot fix of Aspose.BarCode for Java (5.4.2). Which is expected after one or two weeks. We will inform you via this forum thread as soon as it is published.

The issues you have found earlier (filed as BARCODJAVA-33325) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.