NullPointerException in BarCodeReader

Hi there,


i am testing to read barcodes from pdf.
In the first step i use the PdfConverter to convert the pdf as png.
Then i use BarCodeReader to read the Barcodes.

My Problem:
If i set converter.setResolution(150) it works. Any other resolution ends in a NullPointerException while barcodereader.read().

Does anyone know this issue?
I’m using pdf-kit-4.0.0 and barcode-2.7.0.

Hi,


Thank you for considering Aspose products.

I am afraid, I will require your sample PDF file to reproduce your said exception.

Unless you have some requirements other than scanning barcode from PDF, you can also extract the images from a PDF file using the PdfExtractor Class instead of PdfConverter. For your reference please check the Technical Article.

Thanks for your reply.
Here is my PDF file.
Meanwhile i try to read the barcodes with extracting the images.

Edit: The Problem only occurs with the BarCodeReadType.AllSupportedTypes

Hi,


Thank you for providing your sample file. I am able to reproduce the said exception, so I have recorded it in our bug tracking system under ticket id 31409. As soon as we receive any updates, we will post here.

Below is source code for your reference:
JAVA
PdfExtractor extractor = new PdfExtractor();
extractor.bindPdf(“c:/temp/test15.pdf”);
extractor.setEndPage(1);
extractor.setStartPage(1);
extractor.extractImage();

while (extractor.hasNextImage())
{
String strBarCodeImage = “c:/temp/barcode.png”;
extractor.getNextImage(strBarCodeImage, ImageType.PNG);

// recognize barcode from image
BarCodeReader reader = new BarCodeReader(Toolkit.getDefaultToolkit().getImage(strBarCodeImage), BarCodeReadType.AllSupportedTypes);
while (reader.read())
{
System.out.println("codetext: " + reader.getCodeText());
}
}

Hi Benjamin,


Thanks for your patience. Could you please try using Aspose.Pdf.Kit for Java 4.5.0 and Aspose.BarCode for Java 5.3.0 and let us know how it goes on your side? Because I’m able to extract and recognize the bar code image.