PDFBox-PDF到图像丢失的条形码 [英] PDFBox - PDF to Image losing barcode

查看:211
本文介绍了PDFBox-PDF到图像丢失的条形码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PDFBox并具有以下代码片段,该片段正在读取PDF文件并将其转换为图像(PNG).它运作良好,唯一的问题是它完全失去了PDF文件中的条形码值.

I am using PDFBox and have the following code snippet, which is reading a PDF file and converting it to image (PNG). It is working well, the only problem is that it is completely losing the barcode value that is in the PDF file.

有人知道如何使用PDFBox解决此问题吗?那有可能吗?谢谢.

Does anyone know how to work around this with PDFBox? Is that even possible? Thanks.

PDDocument doc = PDDocument.load(new File("INPUT.pdf"));
PDPage page = (PDPage) doc.getDocumentCatalog().getAllPages().get(0);
BufferedImage image = page.convertToImage();
File outputfile = new File("image.png");
ImageIO.write(image, "png", outputfile);

推荐答案

条形码图像格式为pdfbox无法识别. 您缺少诸如此类的一些可选扩展名:

The barcode image is in a format that is not recognized by pdfbox. You are missing some optional extensions like these:

  • 读取JBIG2图像:JBIG2 ImageIO或JBIG2-Image-Decoder
  • 读取JPEG 2000(JPX)图像:JAI图像I/O工具核心

此处有更多信息.

这篇关于PDFBox-PDF到图像丢失的条形码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆