ICEpdf
  1. ICEpdf
  2. PDF-434

IllegalArgumentException: Width (2480) and height (0) must be > 0

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.3.2
    • Fix Version/s: 4.3.3
    • Component/s: Core/Parsing
    • Labels:
      None
    • Environment:
      All

      Description

      The following exceptions are thrown when loading a PDF:

      FINE: Error building image raster.
      java.lang.IllegalArgumentException: Width (2480) and height (0) must be > 0
      at java.awt.image.SampleModel.<init>(SampleModel.java:108)
      at java.awt.image.MultiPixelPackedSampleModel.<init>(MultiPixelPackedSampleModel.java:129)
      at java.awt.image.MultiPixelPackedSampleModel.<init>(MultiPixelPackedSampleModel.java:89)
      at java.awt.image.Raster.createPackedRaster(Raster.java:843)
      at org.icepdf.core.pobjects.Stream.makeImageWithRasterFromBytes(Stream.java:2492)
      at org.icepdf.core.pobjects.Stream.getImage(Stream.java:2387)
      at org.icepdf.core.pobjects.Stream.getImage(Stream.java:2250)
      at org.icepdf.core.pobjects.Resources.getImage(Resources.java:246)
      at org.icepdf.core.util.ContentParser.consume_Do(ContentParser.java:1980)
      at org.icepdf.core.util.ContentParser.parse(ContentParser.java:373)
      at org.icepdf.core.pobjects.Page.init(Page.java:372)
      at org.icepdf.core.views.swing.PageViewComponentImpl$PageInitilizer.run(PageViewComponentImpl.java:1072)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
      14-May-2012 10:34:26 AM org.icepdf.core.pobjects.Resources getImage
      FINE: Error getting image by name: Im0
      java.lang.IllegalArgumentException: Width (2480) and height (0) cannot be <= 0
      at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)
      at java.awt.image.BufferedImage.<init>(BufferedImage.java:321)
      at org.icepdf.core.pobjects.Stream.parseImage(Stream.java:2751)
      at org.icepdf.core.pobjects.Stream.getImage(Stream.java:2411)
      at org.icepdf.core.pobjects.Stream.getImage(Stream.java:2250)
      at org.icepdf.core.pobjects.Resources.getImage(Resources.java:246)
      at org.icepdf.core.util.ContentParser.consume_Do(ContentParser.java:1980)
      at org.icepdf.core.util.ContentParser.parse(ContentParser.java:373)
      at org.icepdf.core.pobjects.Page.init(Page.java:372)
      at org.icepdf.core.views.swing.PageViewComponentImpl$PageInitilizer.run(PageViewComponentImpl.java:1072)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)

        Activity

        Arran Mccullough created issue -
        Arran Mccullough made changes -
        Field Original Value New Value
        Salesforce Case [5007000000MG2ZH]
        Hide
        Patrick Corless added a comment -

        After a quick look the PDF in question is malformed in that the height of the image is not addressable. In this particular case the image is build a pixel at a time using two for loops for width and height. It should be possible to figure out the height of the image given the image width and colour depth.

        Show
        Patrick Corless added a comment - After a quick look the PDF in question is malformed in that the height of the image is not addressable. In this particular case the image is build a pixel at a time using two for loops for width and height. It should be possible to figure out the height of the image given the image width and colour depth.
        Patrick Corless made changes -
        Fix Version/s 4.3.3 [ 10333 ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #30229 Wed Jul 25 09:24:42 MDT 2012 patrick.corless PDF-434 added a small check for height equals zero and assign the width. This tries to address a few malformed PDF that do not correctly specify the image height.
        Files Changed
        Commit graph MODIFY /icepdf/trunk/icepdf/core/src/org/icepdf/core/pobjects/Stream.java
        Hide
        Patrick Corless added a comment -

        There isn't much we can do at this time as the height for CCITTFax decode is extremely important for proper decode. If I set-up the height = width, most of the Image becomes visible. The PDF in this case is malformed, and is missing content for the object references 9 and 19. If the PDF is part of a creation process then it would be best to addresses why the height reference is not being written.

        The only other possibility here is to look more closely at the CCITTFax specification see if there is any header data that can be read to determine the image height.

        Show
        Patrick Corless added a comment - There isn't much we can do at this time as the height for CCITTFax decode is extremely important for proper decode. If I set-up the height = width, most of the Image becomes visible. The PDF in this case is malformed, and is missing content for the object references 9 and 19. If the PDF is part of a creation process then it would be best to addresses why the height reference is not being written. The only other possibility here is to look more closely at the CCITTFax specification see if there is any header data that can be read to determine the image height.
        Patrick Corless made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Patrick Corless made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: