[ 
https://issues.apache.org/jira/browse/PDFBOX-3653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15836316#comment-15836316
 ] 

Tilman Hausherr edited comment on PDFBOX-3653 at 1/24/17 8:35 PM:
------------------------------------------------------------------

I have set a maximum surface of 25000000 for a pattern image, this is 5000 x 
5000 and dpi isn't even counted.

Initially, this check activated only with your file and another ( 
https://bugs.ghostscript.com/show_bug.cgi?id=693134 ) that doesn't have an 
issue here yet. The values are arbitrary and there might still be trouble with 
a large dpi. Your file renders fine up to 400% (= 288dpi), but not at 1000% 
(720dpi).

I also tried to limit the sizes to the page sizes, but that didn't work with 
several other files; I suspect that at a later time, the calculated large 
patterns get resized so their full surface is needed.

I have also decided to remove the code that sets big (> 32767) XStep and YStep 
values to 0. Rendering with the modified code shows improvements:
- PDFBOX-3447-XStep99999.pdf: the pattern repetition at the top (didn't notice 
before, it is on top of the blue part) is gone
- PDFJS-6496-XStep99999.pdf: the pattern repetition at the right (didn't notice 
before, the dotted line was double) is gone
- PDFJS-7731-XStep99999.pdf: the pattern repetition at the bottom (easy to see) 
is gone

An even better solution for the future would be to paint patterns with big 
sizes only once, i.e. not use TexturePaint.


was (Author: tilman):
I have set a maximum surface of 25000000 for a pattern image, this is 5000 x 
5000 and dpi isn't even counted.

Initially, this check activated only with your file and another ( 
https://bugs.ghostscript.com/show_bug.cgi?id=693134 ) that doesn't have an 
issue here yet. The values are arbitrary and there might still be trouble with 
a large dpi. Your file renders fine up to 400% (= 288dpi), but not at 1000% 
(720dpi).

I also tried to limit the sizes to the page sizes, but that didn't work with 
several other files; I suspect that at a later time, the calculated large 
patterns get resized so their full surface is needed.

I have also decided to remove the code that sets big (> 32767) XStep and YStep 
values to 0. Rendering with the modified code shows improvements:
- PDFBOX-3447-XStep99999.pdf: the pattern repetition at the top (didn't notice 
before, it is on top of the blue part) is gone
- PDFJS-6496-XStep99999.pdf: the pattern repetition at the right (didn't notice 
before, the dotted line was double) is gone
- PDFJS-7731-XStep99999.pdf: the pattern repetition at the bottom (easy to see) 
is gone

An even better solution for the future would be to paint patterns with big 
sizes only once, i.e. not use TexturePaint.

> NegativeArraySizeException thrown when converting PDF to Image (in 
> TilingPaint.java)
> ------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-3653
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3653
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.4
>            Reporter: Emily Coyne
>            Assignee: Tilman Hausherr
>             Fix For: 2.0.5, 2.1.0
>
>         Attachments: PDFBOX-3653_reduced.pdf, PowerPoint-slides.pdf
>
>
> Specifically page 7 of the PDF document is failing.
> PDF Document:
> http://download.win2pdf.com/samples/PowerPoint-slides.pdf
> (also attached to ticket)
> Stack trace:
> 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 org.apache.pdfbox.rendering.TilingPaint.getImage(TilingPaint.java:134)
> at org.apache.pdfbox.rendering.TilingPaint.<init>(TilingPaint.java:69)
> at org.apache.pdfbox.rendering.PageDrawer.getPaint(PageDrawer.java:251)
> at 
> org.apache.pdfbox.rendering.PageDrawer.getNonStrokingPaint(PageDrawer.java:526)
> at org.apache.pdfbox.rendering.PageDrawer.fillPath(PageDrawer.java:597)
> at 
> org.apache.pdfbox.contentstream.operator.graphics.FillEvenOddRule.process(FillEvenOddRule.java:36)
> at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:829)
> at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:486)
> at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:460)
> at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:150)
> at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:189)
> at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:145)
> at 
> org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:94)
> at org.apache.pdfbox.tools.PDFToImage.main(PDFToImage.java:236)
> at org.apache.pdfbox.tools.PDFBox.main(PDFBox.java:94)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to