Free Support Forum -

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
{"*** 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);
		   outputStream = new;
		   inputStream = new (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) (;
	            	if (_imageReader != null) {
	            		_imageReader.setInput(iis, true);
	            		// Feed each page to the BarCodeReader
	            		for (int i = 0; i < pageCount; i++) {
	            			BufferedImage _bufferedImage =;
	            			BarCodeReader reader1 = new BarCodeReader(_bufferedImage, DecodeType.QR);
	            			// Read the barcodes in a single page
	            			for (BarCodeResult result : reader1.readBarCodes()) {

    } catch(Exception e) {"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: