Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 5.0.6_P01, 5.0.7
-
Fix Version/s: 5.1
-
Component/s: Core/Parsing
-
Labels:None
-
Environment:All
-
Support Case References:Support Case #12987 - https://icesoft.my.salesforce.com/5007000000fGFFi
Description
When rendering the provided PDF file, the following error is thrown and the PDF fails to render:
java.lang.ClassCastException: org.icepdf.core.pobjects.functions.postscript.Expression cannot be cast to java.lang.Float
at org.icepdf.core.pobjects.functions.postscript.OperatorFactory$18.eval(OperatorFactory.java:328)
at org.icepdf.core.pobjects.functions.postscript.Lexer.operandStart(Lexer.java:225)
at org.icepdf.core.pobjects.functions.postscript.Lexer.parse(Lexer.java:112)
at org.icepdf.core.pobjects.functions.Function_4.calculate(Function_4.java:95)
at org.icepdf.core.pobjects.graphics.Separation.getColor(Separation.java:179)
at org.icepdf.core.util.content.AbstractContentParser.consume_sc(AbstractContentParser.java:414)
at org.icepdf.core.util.content.NContentParser.parse(Unknown Source)
at org.icepdf.core.pobjects.Page.init(Page.java:370)
at org.icepdf.ri.common.views.PageViewComponentImpl$PageInitializer.run(PageViewComponentImpl.java:1065)
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:745)
java.lang.ClassCastException: org.icepdf.core.pobjects.functions.postscript.Expression cannot be cast to java.lang.Float
at org.icepdf.core.pobjects.functions.postscript.OperatorFactory$18.eval(OperatorFactory.java:328)
at org.icepdf.core.pobjects.functions.postscript.Lexer.operandStart(Lexer.java:225)
at org.icepdf.core.pobjects.functions.postscript.Lexer.parse(Lexer.java:112)
at org.icepdf.core.pobjects.functions.Function_4.calculate(Function_4.java:95)
at org.icepdf.core.pobjects.graphics.Separation.getColor(Separation.java:179)
at org.icepdf.core.util.content.AbstractContentParser.consume_sc(AbstractContentParser.java:414)
at org.icepdf.core.util.content.NContentParser.parse(Unknown Source)
at org.icepdf.core.pobjects.Page.init(Page.java:370)
at org.icepdf.ri.common.views.PageViewComponentImpl$PageInitializer.run(PageViewComponentImpl.java:1065)
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:745)
The type 4 function in question uses a few operands we didn't previously have a test case for. Our lexer gets into trouble when we encounters the ifelse and exp operands.
The lexer has been rewords and the notation of a Procedure has been introduce to aid in the property handling of the ifelse and if statements. After implementing the Procedures class it as also noticed the most of the Math.* functions where putting double values on the stack. This methods were updated to return float values.
For references purposes the function is defined as:
{dup 0 lt
{pop 0 }{dup 1 gt {pop 1 } if } ifelse 0 index 1 exp 1 mul 0 add dup 0 lt {pop 0 }{dup 1 gt
{pop 1 } if } ifelse 1 index 1 exp 0 mul 0 add dup 0 lt {pop 0 }{dup 1 gt {pop 1 }if } ifelse 2 index 1 exp 0 mul 0 add dup 0 lt
{pop 0 }{dup 1 gt {pop 1 } if } ifelse 3 index 1 exp 0 mul 0 add dup 0 lt {pop 0 }{dup 1 gt
{pop 1 }if } ifelse 5 4 roll pop }