You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2018/09/29 11:45:00 UTC

[jira] [Updated] (PDFBOX-4326) PDF with JPEG2000 image can't be rendered

     [ https://issues.apache.org/jira/browse/PDFBOX-4326?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tilman Hausherr updated PDFBOX-4326:
------------------------------------
    Description: 
There is an EOF exception:
{noformat}
    java.io.EOFException
    at javax.imageio.stream.ImageInputStreamImpl.readBits(ImageInputStreamImpl.java:687)
    at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.fromAny(SampledImageReader.java:523)
    at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:217)
    at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:418)
    at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:400)
    at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:1021) 
{noformat}
The EOF exception is because SampledImageReader expects a stream that is 3x longer than actually appears, because the colorspace is said to have 3 colors instead of 1. This is because the JPEG2000 plugin returns an image with IndexColorModel which references three colors.

There are two ways to solve this and both worked: the slower is to convert to RGB which requires another change when reading the raster (because the raster is now made if intergers), the faster is to force a gray colorspace. I use the later but keep the change I made in passing the raster, we may need it some day.

I'm making the change only for the trunk for now, and to the 2.0 branch after release of 2.0.12.

  was:
There is an EOF exception:
{noformat}
    java.io.EOFException
    at javax.imageio.stream.ImageInputStreamImpl.readBits(ImageInputStreamImpl.java:687)
    at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.fromAny(SampledImageReader.java:523)
    at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:217)
    at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:418)
    at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:400)
    at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:1021) 
{noformat}
The EOF exception is because SampledImageReader expects a stream that is 3x longer than actually appears, because the colorspace is said to have 3 colors instead of 1. This is because the plugin returns an image with IndexColorModel which references three colors.

There are two ways to solve this and both worked: the slower is to convert to RGB which requires another change when reading the raster (because the raster is now made if intergers), the faster is to force a gray colorspace. I use the later but keep the change I made in passing the raster, we may need it some day.

I'm making the change only for the trunk for now, and to the 2.0 branch after release of 2.0.12.


> PDF with JPEG2000 image can't be rendered
> -----------------------------------------
>
>                 Key: PDFBOX-4326
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4326
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 2.0.11
>            Reporter: Tilman Hausherr
>            Assignee: Tilman Hausherr
>            Priority: Major
>              Labels: JPEG2000, JPXDecode, JPXFilter
>             Fix For: 2.0.13, 3.0.0 PDFBox
>
>         Attachments: PDFJS-10026.jp2, PDFJS-10026.pdf
>
>
> There is an EOF exception:
> {noformat}
>     java.io.EOFException
>     at javax.imageio.stream.ImageInputStreamImpl.readBits(ImageInputStreamImpl.java:687)
>     at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.fromAny(SampledImageReader.java:523)
>     at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:217)
>     at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:418)
>     at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:400)
>     at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:1021) 
> {noformat}
> The EOF exception is because SampledImageReader expects a stream that is 3x longer than actually appears, because the colorspace is said to have 3 colors instead of 1. This is because the JPEG2000 plugin returns an image with IndexColorModel which references three colors.
> There are two ways to solve this and both worked: the slower is to convert to RGB which requires another change when reading the raster (because the raster is now made if intergers), the faster is to force a gray colorspace. I use the later but keep the change I made in passing the raster, we may need it some day.
> I'm making the change only for the trunk for now, and to the 2.0 branch after release of 2.0.12.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org