PDFBox:不提取ExtractImages JPEG2000图像

问题描述

我正在尝试使用PDFBox提取PDF文件中的所有图像。对于包含jpeg和png图像的pdf,它的工作效果很好。但是它不适用于Openjpeg2000图像。我收到以下异常: 出现以下错误

org.apache.pdfBox.contentstream.PDFStreamEngine operatorException
SEVERE: Cannot read jpeg2000 image: Java Advanced Imaging (JAI) Image I/O Tools are not installed

在所有版本的PDFBox中,都会出现相同的异常。也尝试过使用独立的jar。

我也在pom.xml中包括了必要的依赖项。

<dependency>
<groupId>org.apache.pdfBox</groupId>
<artifactId>jbig2-imageio</artifactId>
</dependency>
<!-- For legal reasons (incompatible license),these two dependencies
are to be used only in the tests and may not be distributed. -->
<dependency>
<groupId>com.github.jai-imageio</groupId>
<artifactId>jai-imageio-core</artifactId>
</dependency>
<dependency>
<groupId>com.github.jai-imageio</groupId>
<artifactId>jai-imageio-jpeg2000</artifactId>
</dependency>

任何帮助将不胜感激。

解决方法

将与映像相关的.jar文件复制到lib子目录中,然后使用以下命令行:

java -cp "pdfbox-app-2.0.21.jar;lib/*" org.apache.pdfbox.tools.PDFBox ExtractImages <parameters>

使用“;”在Windows上,在Linux上为“:”。

org.apache.pdfbox.tools.PDFBox是主类的名称。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...