Java ZXING库读取PDF中的QR条形码时出错

Java ZXING库读取PDF中的QR条形码时出错,java,itext,zxing,Java,Itext,Zxing,我使用的是ZXING库,有了这个代码,我可以在我的PDF中获取图像,具体的QR条形码,但是当我试图获取ZXING库中的信息时。。。我找不到条形码 但是如果我从文件中提取相同的条形码,比如barocode.png,效果会很好 image = ImageIO.read(new File("C:\\Workarea\\testBarcode.png")); buffered = (BufferedImage) image; 我怎样才能解决这个问题?库的内部错误是否为ZXING?我必须使用另一个实现

我使用的是ZXING库,有了这个代码,我可以在我的PDF中获取图像,具体的QR条形码,但是当我试图获取ZXING库中的信息时。。。我找不到条形码

但是如果我从文件中提取相同的条形码,比如
barocode.png
,效果会很好

image = ImageIO.read(new File("C:\\Workarea\\testBarcode.png"));

buffered = (BufferedImage) image;
我怎样才能解决这个问题?库的内部错误是否为ZXING?我必须使用另一个实现

我也在用PDFBOX测试,我也有同样的错误

有人能帮我吗

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();
    }
}
public void renderImage(ImageRenderInfo renderInfo){
buffereImage buffered=null;
试一试{
PdfImageObject image1=renderInfo.getImage();
亮度源;
字节[]imageInByte=image1.getImageAsBytes();
InputStream in=新的ByteArrayInputStream(imageInByte);
BuffereImage bImageFromConvert=ImageIO.read(in);
source=新的BufferedImageLuminanceSource(bImageFromConvert);
BinaryBitmap位图=新的BinaryBitmap(新的混合二进制程序(源));
结果=新的MultiFormatReader()。解码(位图);
ParsedResult ParsedResult=ResultParser.parseResult(结果);
System.out.println(“(格式:“+result.getBarcodeFormat()+”,类型:”+
parsedResult.getType()+“”:\n原始结果:\n“+result.getText()+”\n解析结果:\n”+
parsedResult.getDisplayResult());
System.out.println(“find”+result.getResultPoints().length+“result points”);
for(int i=0;i


您的代码正在检查PDF中的位图图像中的条形码。你确定条形码在这样的位图中吗?它也可以使用矢量图形绘制或使用某种条形码字体书写。如果你不确定,请提供一个样本PDF供检查。我发现我在使用我的PDF时只有错误,如果我使用其他图像工作,检查问题,我看到我的BuffereImage工作时有#pixelBits=8,不工作时有1,现在的问题是我如何在不更改原始图像的情况下修复它,因为我不能。有什么想法吗?我对条形码的类型有一个错误,不是QR是一个数据矩阵ECC200,而是读取内容的唯一方法是用一个更大的图像和一个白色边框包围数据矩阵