简体   繁体   中英

PDFBox: ExtractImages JPEG2000 images not extracting

I am trying to extract all the images in a PDF file using PDFBox. Its working fine for the pdf containing jpeg and png images. But it is not working for OpenJPEG2000 images. I am getting the below exception: Getting the below error:

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

In all version of PDFBox, same exception is coming. Tried with standalone jar as well.

I included the necessary dependencies in pom.xml as well.

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

Any help will be appreciated.

Copy the imageing related .jar files into the lib subdirectory, and then use this command line:

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

Use ";" on windows, ":" on linux.

org.apache.pdfbox.tools.PDFBox is the name of the main class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM