Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 5.0.5
-
Fix Version/s: 5.0.6
-
Component/s: Core/Parsing
-
Labels:None
-
Environment:Levigo JBIG2 library
-
Support Case References:
-
Workaround Exists:Yes
-
Workaround Description:Remove the levigo jar file from the classpath
Description
When loading the PDF provided from the customer, the following error stack trace is thrown. When removing the levigo jar from the class path the PDF renders fine without any errors.
WARNING: Problem loading JBIG2 image:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.icepdf.core.pobjects.ImageStream.jbig2Decode(ImageStream.java:743)
at org.icepdf.core.pobjects.ImageStream.getImage(ImageStream.java:373)
at org.icepdf.core.pobjects.ImageStream.getImage(ImageStream.java:306)
at org.icepdf.core.pobjects.graphics.SmoothScaledImageReference.call(SmoothScaledImageReference.java:95)
at org.icepdf.core.pobjects.graphics.SmoothScaledImageReference.call(SmoothScaledImageReference.java:39)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: Can't instantiate segment class
at com.levigo.jbig2.SegmentHeader.getSegmentData(SegmentHeader.java:405)
at com.levigo.jbig2.JBIG2Page.createNormalPage(JBIG2Page.java:182)
at com.levigo.jbig2.JBIG2Page.createPage(JBIG2Page.java:154)
at com.levigo.jbig2.JBIG2Page.composePageBitmap(JBIG2Page.java:145)
at com.levigo.jbig2.JBIG2Page.getBitmap(JBIG2Page.java:125)
at com.levigo.jbig2.JBIG2ImageReader.read(JBIG2ImageReader.java:223)
at javax.imageio.ImageReader.read(ImageReader.java:940)
... 14 more
Caused by: java.lang.RuntimeException: Can't instantiate segment class
at com.levigo.jbig2.SegmentHeader.getSegmentData(SegmentHeader.java:405)
at com.levigo.jbig2.segments.TextRegion.initSymbols(TextRegion.java:818)
at com.levigo.jbig2.segments.TextRegion.getSymbols(TextRegion.java:249)
at com.levigo.jbig2.segments.TextRegion.parseHeader(TextRegion.java:151)
at com.levigo.jbig2.segments.TextRegion.init(TextRegion.java:901)
at com.levigo.jbig2.SegmentHeader.getSegmentData(SegmentHeader.java:400)
... 20 more
Caused by: java.lang.NullPointerException
at com.levigo.jbig2.segments.SymbolDictionary.retrieveImportSymbols(SymbolDictionary.java:816)
at com.levigo.jbig2.segments.SymbolDictionary.setInSyms(SymbolDictionary.java:242)
at com.levigo.jbig2.segments.SymbolDictionary.parseHeader(SymbolDictionary.java:131)
at com.levigo.jbig2.segments.SymbolDictionary.init(SymbolDictionary.java:844)
at com.levigo.jbig2.SegmentHeader.getSegmentData(SegmentHeader.java:400)
... 25 more
WARNING: Problem loading JBIG2 image:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.icepdf.core.pobjects.ImageStream.jbig2Decode(ImageStream.java:743)
at org.icepdf.core.pobjects.ImageStream.getImage(ImageStream.java:373)
at org.icepdf.core.pobjects.ImageStream.getImage(ImageStream.java:306)
at org.icepdf.core.pobjects.graphics.SmoothScaledImageReference.call(SmoothScaledImageReference.java:95)
at org.icepdf.core.pobjects.graphics.SmoothScaledImageReference.call(SmoothScaledImageReference.java:39)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: Can't instantiate segment class
at com.levigo.jbig2.SegmentHeader.getSegmentData(SegmentHeader.java:405)
at com.levigo.jbig2.JBIG2Page.createNormalPage(JBIG2Page.java:182)
at com.levigo.jbig2.JBIG2Page.createPage(JBIG2Page.java:154)
at com.levigo.jbig2.JBIG2Page.composePageBitmap(JBIG2Page.java:145)
at com.levigo.jbig2.JBIG2Page.getBitmap(JBIG2Page.java:125)
at com.levigo.jbig2.JBIG2ImageReader.read(JBIG2ImageReader.java:223)
at javax.imageio.ImageReader.read(ImageReader.java:940)
... 14 more
Caused by: java.lang.RuntimeException: Can't instantiate segment class
at com.levigo.jbig2.SegmentHeader.getSegmentData(SegmentHeader.java:405)
at com.levigo.jbig2.segments.TextRegion.initSymbols(TextRegion.java:818)
at com.levigo.jbig2.segments.TextRegion.getSymbols(TextRegion.java:249)
at com.levigo.jbig2.segments.TextRegion.parseHeader(TextRegion.java:151)
at com.levigo.jbig2.segments.TextRegion.init(TextRegion.java:901)
at com.levigo.jbig2.SegmentHeader.getSegmentData(SegmentHeader.java:400)
... 20 more
Caused by: java.lang.NullPointerException
at com.levigo.jbig2.segments.SymbolDictionary.retrieveImportSymbols(SymbolDictionary.java:816)
at com.levigo.jbig2.segments.SymbolDictionary.setInSyms(SymbolDictionary.java:242)
at com.levigo.jbig2.segments.SymbolDictionary.parseHeader(SymbolDictionary.java:131)
at com.levigo.jbig2.segments.SymbolDictionary.init(SymbolDictionary.java:844)
at com.levigo.jbig2.SegmentHeader.getSegmentData(SegmentHeader.java:400)
... 25 more
Issue Links
- is duplicated by
-
PDF-728 Problem loading JBIG2 image: InvocationTargetException
- Closed
The underlying issue with the PDF in question is that when the image on page 3 is loaded there is an error building the Huffman tree. I've been reviewing the code but have yet to find cause.
Basically when the 4 node is entered into the tree there appear to be a length issue where the the int 2316 is truncated into a 10 digit binarray number. So 100100001011 get truncated to 0100001011 as the Huffman path.
The problem here is that at node 421 we get the int 267 which when converted to binary is 0100001011 and we have a collision when building the tree.
The image is located on page 3 of the sample document BlackPagesCany.....pdf. I'll create a seperate but for this issue for for the time being we have code in place that will try and load the image using the levigo library and on failure will fall back and try to load the image using the default core implementation of the Jbig2 which address the test cases attached to this case.