Java-PDFBox-PDF和JBIG2图像
我在使用PDFBox API时遇到问题。 我有一个带有JBIG2图像的PDF文件,我想把它读出来,然后创建一个带有PDF内容的JPEG或PNG文件。 不幸的是,我只得到了一张黑色的照片 我的代码是:Java-PDFBox-PDF和JBIG2图像,java,image,pdf,pdfbox,jbig2,Java,Image,Pdf,Pdfbox,Jbig2,我在使用PDFBox API时遇到问题。 我有一个带有JBIG2图像的PDF文件,我想把它读出来,然后创建一个带有PDF内容的JPEG或PNG文件。 不幸的是,我只得到了一张黑色的照片 我的代码是: public static void copyDocumentAsImage(String path) throws IOException { PDDocument document = PDDocument.load(new File(path)); String
public static void copyDocumentAsImage(String path) throws IOException {
PDDocument document = PDDocument.load(new File(path));
String destinationDir = "myDestinationPath";
BufferedImage img = new BufferedImage(2000, 2000, BufferedImage.TYPE_BYTE_GRAY);
PDXObjectImage ximage = new PDJpeg(document, img);
ximage.write2file(destinationDir);
}
我已经检查过了:但这对我不起作用,或者我没有得到正确的解决方案 有人能帮我吗
提前感谢。JBIG2图像由可选扩展处理,可能不是您提供的: 读取JBIG2图像:JBIG2图像IO或JBIG2图像解码器 只需从Maven加载此依赖项:
<dependency>
<groupId>com.levigo.jbig2</groupId>
<artifactId>levigo-jbig2-imageio</artifactId>
<version>1.6.5</version>
</dependency>
com.levigo.jbig2
.你能链接pdf文件吗?我正在处理一个可能相关的问题: