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

Free Support Forum - aspose.com

Aspose.Barcode issue (reading file taking long time)

We are using aspose.barcode for java, when we are trying to read a PDF document to identify whether barcode is present in the document or not. it is taking more than 10 minutes to perform the activity for some set of documents. And because of the long waiting time, causes disruption to the entire sequence of activities. Kindly let us know whether do we have timeout functionality and image enhancing abilities with Aspose.barcode for java libraries


Please zip your file and paste your sample code (runnable) to reproduce the issue on our end, we will check it soon.

The file contains confidential information, I am working with the team to create a new file similar to the one we are facing the issue.


Please take your time to create similar file to reproduce the issue on our end.

Hi Team, I checked with our business team, they were not possible to recreate the documents which caused the issue, following are the brief description of the document
Total number of pages: 8
All 8 pages are images
Document Format: PDF
Document Size: 1.6 MB
On reading the 3rd page which contains the passport image (third page), the reader is taking more than 10 mins.
All the images are black and white in color
image pixel details:
Page 1: Horizontal: 2552 Vertical: 3300
Page 2: Horizontal: 2564 Vertical: 3309
Passport page: Horizontal: 3323 Vertical: 2582

We are afraid that this information is not helpful in reproducing the issue here. Please share some dummy data and runnable sample code that can be used to recreate the issue here, otherwise it will not be possible for us to assist you further.

Hi Team,

Please find the attached PDF documents (we have redacted the confidential information, both redacted and unredacted files are causing the issue), in our coding logic when we multiple files we will check all the file subsequently for presence of barcode, refer to the coding that we are using
Redacted File 1.pdf (1.7 MB)
Redacted File 2.pdf (1.7 MB)

The code is getting stuck on the line "com.aspose.barcode.barcoderecognition.BarCodeReader reader = new com.aspose.barcode.barcoderecognition.BarCodeReader(inputStream,com.aspose.barcode.barcoderecognition.DecodeType.QR);"

public List getBarCodeTextList(ServiceFactory serviceFactory, List attachments, int barcodePdfPagefetchSize, int barcodeTiffPagefetchSize) throws Exception
LOGGER.info("*** Barcode Recognition: getBarCodeTextList ****");
List barCodeTextList = new ArrayList();
try {

        for (Document attachment : attachments) {
                byte[] docxContents =
                InputStream stream = new ByteArrayInputStream(docxContents);
                com.aspose.pdf.facades.PdfExtractor objextractor = new com.aspose.pdf.facades.PdfExtractor();
				int imageCount = 1;
		            System.out.println("Extracting image " + imageCount);
		            java.io.ByteArrayOutputStream outputStream = new java.io.ByteArrayOutputStream();
		            java.io.ByteArrayInputStream inputStream = new java.io.ByteArrayInputStream (outputStream.toByteArray());
		            // Recognize barcode from image
		            com.aspose.barcode.barcoderecognition.BarCodeReader reader = new com.aspose.barcode.barcoderecognition.BarCodeReader(inputStream,com.aspose.barcode.barcoderecognition.DecodeType.QR);
//		            reader.setQualitySettings(QualitySettings.getMaxBarCodes());
		            for(BarCodeResult result : reader.readBarCodes())
        	else if(attachment.getName()!=null && (attachment.getName().toLowerCase().endsWith(".tiff")) ||(attachment.getName().toLowerCase().endsWith(".tif")))
        		//String fileName = attachment.getName();	
                byte[] docxContents =
      	      InputStream myInputStream = new ByteArrayInputStream(docxContents); 
    	      ByteArrayInputStream input = new ByteArrayInputStream(docxContents);
        		Iterator<ImageReader> readers = javax.imageio.ImageIO.getImageReadersBySuffix("tiff");
        		if (readers.hasNext()) {
		        	//File fi = new File(fileName);
		        	ImageInputStream iis = javax.imageio.ImageIO.createImageInputStream(input);
		        	TIFFDecodeParam param = null;
		        	ImageDecoder dec = ImageCodec.createImageDecoder("tiff", myInputStream, param);
	            	// Get the page count of the TIFF image
	            	int pageCount = dec.getNumPages();
	            	if(barcodeTiffPagefetchSize>=0 && pageCount>barcodeTiffPagefetchSize)
	            		pageCount = barcodeTiffPagefetchSize;
	            	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);
	            			BarCodeReader reader1 = new BarCodeReader(_bufferedImage, DecodeType.QR);
	            			// Read the barcodes in a single page
	            			for (BarCodeResult result : reader1.readBarCodes()) {

    } catch(Exception e) {
		LOGGER.info("Exception in getBarCodeTextList"+e.getMessage());
    return barCodeTextList;


Kindly review and provide us your feedback

getMaxBarCodes is special quality mode and recognition in this mode on full A4 could take almost hour.

Hi Alexander,
we are are not using the setQualitySettings function, as you can see from the code it is already commented out.coding commented out already.png (52.6 KB)

We have observed this issue and logged it in our database for further investigation. You will be notified here once any update is ready for sharing.

This issue is logged as:
BARCODEJAVA-1068 - BarCodeReader.readBarCodes hangs while reading barcodes from the attached PDF file

@ahsaniqbalsidiqui Thanks for logging the case with Aspose Team, Kindly let me know ETA on the resolution for the issue logged.


Please spare us little time (e.g. a few days) so we could evaluate and analyze your issue in details. Then, we will be able to share an ETA or update on it.

Once we have any new information available, we will share it with you.

@Amjad_Sahi, Sure :slight_smile:

Hi Team, any updates on the issue fix progress.


We are sorry but still there is no update available for your issue. We will gather information and get back to you soon.

Sorry for any inconvenience caused!

Hi Team,

Kindly let me know whether there are any updates for the above mentioned issue.

With Regards,
Saravana Kumar


We investigated your issue. Actually, the time consumed for finding and recognition is much less in .NET in comparison with Java. We are sorry but the issue demands more deep investigation. We hope, it will be fixed in Aspose.BarCode for Java 21.4 release.

We are sorry for any inconvenience caused!

Hi Team,
Do you have any updates on the above mentioned issue, of lately we are frequently receiving files which are taking a very long time to process. Which in turn causing several cascading issues.

Hope there is a positive progress on this issue.

Also, is it possible to get the timeout sample code from the following thread and the sample barcode image in the same thread.

I am afraid that the issue is not resolved yet. We will inform you once it will be fixed.

Yes, the sample code and image are template files created by us for testing purpose so you can download it from here. timeout_test.zip (80.1 KB)