Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.0.32, 3.0.3 PDFBox
-
None
Description
https://github.com/dbmdz/imageio-jnr / https://mvnrepository.com/artifact/de.digitalcollections.imageio/imageio-openjpeg is an alternative JPEG2000 implementation for Java ImageIO that uses the native OpenJPEG library as its backend.
Unfortunately, it doesn't work out of the box because it doesn't implement raster reading (canReadRaster not overridden, returns false), and PDFBox uses canReadRaster() to validate image reader instances. However, it doesn't appear that there is any real reliance on raster support in PDFBox (at least in version 3) - if I patch the library to lie about raster support, it seems to work perfectly.
A further complication arises when the OpenJPEG native library cannot be found: imageio-openjpeg returns null as the reader instance, which causes PDF rendering to fail with an NPE, even if another JPEG2000 reader is available. This can be remedied with a simple null check.
https://github.com/apache/pdfbox/pull/197 shows a possible solution. Until then, https://github.com/Googulator/imageio-jnr can be used with PDFBox 3.0.3 as a workaround, so long as the native library is correctly installed.
Attachments
Issue Links
- links to