PDFBox - PDF to Image losing barcode

微笑、不失礼 提交于 2019-12-13 01:12:38

问题


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.

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);

回答1:


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

  • Reading JBIG2 images: JBIG2 ImageIO or JBIG2-Image-Decoder
  • Reading JPEG 2000 (JPX) images: JAI Image I/O Tools Core

More information here.



来源:https://stackoverflow.com/questions/22028433/pdfbox-pdf-to-image-losing-barcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!