当前位置: 首页 > 面试题库 >

Issue in getImageWritersByFormatName for Tiff. Getting image writer

聂涛
2023-03-14
问题内容

I am trying to convert PDF to tif images. I use following code to get the
image writers by format.

Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("TIFF");

        if (writers == null || !writers.hasNext()) {
            throw new ImageWritingException();
        }

This works fine when I run the application standalone in Eclipse. But when I
deploy the application to tomcat server in linux, writers==null is false
but !writers.hasNext is true resulting to throw Exception.

I use maven to build the project to war.

I have following dependencies in the pom file.

<dependency>
            <groupId>org.icepdf</groupId>
            <artifactId>icepdf-core</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.media</groupId>
            <artifactId>jai_imageio</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.media</groupId>
            <artifactId>jai-codec</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.media</groupId>
            <artifactId>jai_core</artifactId>
        </dependency>

What can be the difference between two environments? How can I fix this issue?


问题答案:

Tiff support is provided by the Java Advanced Imaging plugin jai_core.jar.

In order to work correctly, the jar file needs to be added to the JVM’s ext
directory, otherwise it won’t register properly



 类似资料:

相关阅读

相关文章

相关问答