How do I convert to/from XOD and multipage TIFF, using only in-memory streaming, on Java?

Q:

I want to convert multipage TIFF files, obtained from a stream, into in-memory XODs that I can also stream out. Similarly, I want to take in-memory XODs and stream them out as multipage TIFFs. I can’t use any image libraries with unusual licenses. Is there sample code for doing so?

A:

The attached sample code shows how to do convert to and from in-memory XODs and in-memory multipage TIFFs. You can simply use the files attached to this post to replace the PDFDrawTest.java and RunTest.bat included in the draw sample of the “Java, C/C++” builds of the PDFNet SDK (downloadable from https://www.pdftron.com/pdfnet/downloads.html).

The code requires the use of Sun/Oracle’s JAI library, which is explicitly licensed to allow redistribution in commercial software.

Distribution information:
http://download.java.net/media/jai/builds/release/1_1_3/DISTRIBUTIONREADME-jai.txt

http://download.java.net/media/jai-imageio/builds/release/1.1/DISTRIBUTIONREADME-jai_imageio.txt

License allowing use by commercial enterprises:
http://download.java.net/media/jai/builds/release/1_1_3/LICENSE-jai.txt
http://download.java.net/media/jai-imageio/builds/release/1.1/LICENSE-jai_imageio.txt

Downloads:
http://download.java.net/media/jai/builds/release/1_1_3/

http://download.java.net/media/jai-imageio/builds/release/1.1/

As the RunTest.bat file shows, the only required library files are jai_codec.jar, jai_core.jar, and jai_imageio.jar. Note that, as RunTest.bat shows, these jar files may need to be explicitly referenced in the classpath.

PDFDrawTest.java (4.73 KB)

RunTest.bat.txt (241 Bytes)