I'm using ZXING Library, with this code I can get the images in my PDF, concretly QR Barcodes, but when I try to get the information inside ZXING library... I can't find the Barcodes.
But if I take the same barcode from the file like barocode.png
, works perfectly.
image = ImageIO.read(new File("C:\\Workarea\\testBarcode.png"));
buffered = (BufferedImage) image;
How I can fix that? is internal error of the library ZXING? I have to use another implementation?
I was testing with PDFBOX too, and I had the same error.
Anyone can help me?
public void renderImage(ImageRenderInfo renderInfo) {
BufferedImage buffered = null;
try {
PdfImageObject image1 = renderInfo.getImage();
LuminanceSource source;
byte [] imageInByte = image1.getImageAsBytes();
InputStream in = new ByteArrayInputStream(imageInByte);
BufferedImage bImageFromConvert = ImageIO.read(in);
source = new BufferedImageLuminanceSource(bImageFromConvert);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Result result = new MultiFormatReader().decode(bitmap);
ParsedResult parsedResult = ResultParser.parseResult(result);
System.out.println(" (format: " + result.getBarcodeFormat() + ", type: " +
parsedResult.getType() + "):\nRaw result:\n" + result.getText() + "\nParsed result:\n" +
parsedResult.getDisplayResult());
System.out.println("Found " + result.getResultPoints().length + " result points.");
for (int i = 0; i < result.getResultPoints().length; i++) {
ResultPoint rp = result.getResultPoints()[i];
if (rp != null) {
System.out.println(" Point " + i + ": (" + rp.getX() + ',' + rp.getY() + ')');
}
}
} catch (NotFoundException ignored) {
System.out.println("No barcode found!");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}