ICEpdf
  1. ICEpdf
  2. PDF-958

ClassCastException: Stream cannot be cast to ImageStream

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.0.2
    • Fix Version/s: 6.1
    • Component/s: Core/Rendering
    • Labels:
      None
    • Environment:
      All

      Description

      When rendering the provided PDF files the following ClassCastException is thrown and prevents the content from rendering correctly:

      WARNING: Error parsing content stream.
      java.lang.ClassCastException: org.icepdf.core.pobjects.Stream cannot be cast to org.icepdf.core.pobjects.ImageStream
      at org.icepdf.core.util.content.AbstractContentParser.consume_Do(AbstractContentParser.java:640)
      at org.icepdf.core.util.content.NContentParser.parse(Unknown Source)
      at org.icepdf.core.pobjects.Page.init(Page.java:384)
      at org.icepdf.ri.common.views.PageViewComponentImpl$PageInitializer.run(PageViewComponentImpl.java:1169)
      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)

        Activity

        Hide
        Patrick Corless added a comment -

        The generator used to build the PDF in question is putting in an extra character at the end of every dictionary. The character nul or char code zero is the character that is causing the issue. When we are parsing an <<>> dictionary the nul i picked up as an element in the hash and throws of the even number of elements that would normally make up the name value pairs. This is technically a malformed PDF but it's pretty easy for us to fix.

        I've added a quick fix to our object parser which should be OK but a full qa run will needed for this change.

        Show
        Patrick Corless added a comment - The generator used to build the PDF in question is putting in an extra character at the end of every dictionary. The character nul or char code zero is the character that is causing the issue. When we are parsing an <<>> dictionary the nul i picked up as an element in the hash and throws of the even number of elements that would normally make up the name value pairs. This is technically a malformed PDF but it's pretty easy for us to fix. I've added a quick fix to our object parser which should be OK but a full qa run will needed for this change.
        Hide
        Patrick Corless added a comment -

        Marking as fixed.

        Show
        Patrick Corless added a comment - Marking as fixed.
        Hide
        Stefan Bildl added a comment -

        Seems like I have the same problem in newer versions (tested 6.2.2 and 6.3.3).

        Only happens with some PDFs.

        Aug 04, 2020 7:19:32 AM org.icepdf.core.pobjects.Page init
        WARNUNG: Error initializing Page.
        java.lang.ClassCastException: org.icepdf.core.pobjects.Stream cannot be cast to org.icepdf.core.pobjects.graphics.images.ImageStream
        at org.icepdf.core.util.content.AbstractContentParser.consume_Do(AbstractContentParser.java:605)
        at org.icepdf.core.util.content.OContentParser.parse(OContentParser.java:295)
        at org.icepdf.core.pobjects.Page.init(Page.java:436)
        at org.icepdf.ri.common.views.AbstractPageViewComponent$PageImageCaptureTask.call(AbstractPageViewComponent.java:413)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

        Show
        Stefan Bildl added a comment - Seems like I have the same problem in newer versions (tested 6.2.2 and 6.3.3). Only happens with some PDFs. Aug 04, 2020 7:19:32 AM org.icepdf.core.pobjects.Page init WARNUNG: Error initializing Page. java.lang.ClassCastException: org.icepdf.core.pobjects.Stream cannot be cast to org.icepdf.core.pobjects.graphics.images.ImageStream at org.icepdf.core.util.content.AbstractContentParser.consume_Do(AbstractContentParser.java:605) at org.icepdf.core.util.content.OContentParser.parse(OContentParser.java:295) at org.icepdf.core.pobjects.Page.init(Page.java:436) at org.icepdf.ri.common.views.AbstractPageViewComponent$PageImageCaptureTask.call(AbstractPageViewComponent.java:413) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

          People

          • Assignee:
            Patrick Corless
            Reporter:
            Arran Mccullough
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: