pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: Rendering large pages
Date Wed, 04 Oct 2017 18:29:46 GMT
Am 04.10.2017 um 19:52 schrieb jorgeeflorez .:
> Hello all,
>
> When I try to render a large PDF page as an image I get:
> Exception in thread "main" java.lang.NegativeArraySizeException
>      at java.awt.image.DataBufferByte.<init>(DataBufferByte.java:76)
>      at java.awt.image.Raster.createInterleavedRaster(Raster.java:266)
>      at java.awt.image.Raster.createInterleavedRaster(Raster.java:212)
>      at
> java.awt.image.ComponentColorModel.createCompatibleWritableRaster(ComponentColorModel.java:2825)
>      at java.awt.image.BufferedImage.<init>(BufferedImage.java:420)
>      at
> org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.from1Bit(SampledImageReader.java:206)
>      at
> org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:172)
>      at
> org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:403)
>      at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:992)
>      at
> org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:62)
>      at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:838)
>      at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:495)
>      at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:469)
>      at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:150)
>      at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:206)
>      at
> org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:145)
>      at
> org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:94)
>
> The media box of the page is [0.0,0.0,155.53,14394.0]. The library tries to
> create a BufferedImage of 4882x451812 which surpasses Integer.MAX_VALUE
> limit.
>
> IMHO, I think there is not much to do in this case. I think some validation
> should be put (I will do that in my application anyway)  when trying to
> render a large page just like the exception that appears when I try to read
> the image Adobe Acrobat created for the page:

Yes, but what else could we do except throw just another exception?

Btw you might want to try jdk9. I have observed that it allows bigger sizes.

Tilman

>
> Exception in thread "main" java.lang.IllegalArgumentException: width*height
>> Integer.MAX_VALUE!
>      at javax.imageio.ImageReader.getDestination(ImageReader.java:2836)
>      at
> com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1317)
>      at
> com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1614)
>      at javax.imageio.ImageIO.read(ImageIO.java:1448)
>      at javax.imageio.ImageIO.read(ImageIO.java:1308)
>
> Maybe PDFBox should render just a "sector" of a page or as much as it is
> able (I don't now if any of this is even possible)...
>
> Best regards.
>
> Jorge Flórez
>


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


Mime
View raw message