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: [PDFBox 2.0.2] PDFRenderer.renderImageWithDPI throws java.lang.NegativeArraySizeException
Date Mon, 01 Aug 2016 19:56:29 GMT
Am 01.08.2016 um 21:50 schrieb Rafael Pivetta Balbuena:
> Thanks a lot.
> For that file extract the barcode, but for this pdf file
> https://drive.google.com/file/d/0B8GFWmLzuj1QbE1HVENYd3VRems/view?usp=docslist_api
> why don't extract barcode, only four bars (two white and two black bar)?

That is because this file uses a different strategy to display the 
barcode. It just repeats the two images you mentioned.

Tilman

>
> 2016-08-01 16:40 GMT-03:00 Tilman Hausherr <THausherr@t-online.de>:
>
>> Am 01.08.2016 um 21:28 schrieb Rafael Pivetta Balbuena:
>>
>>> Its possible extract images from that file?
>>>
>> Yes, use the ExtractImages command line tool. I just tried it.
>>
>> Tilman
>>
>>
>>
>>> 2016-08-01 16:00 GMT-03:00 Tilman Hausherr <THausherr@t-online.de>:
>>>
>>> Am 01.08.2016 um 20:55 schrieb Rafael Pivetta Balbuena:
>>>> Same error with original PDF file.
>>>>> Original PDF
>>>>>
>>>>>
>>>>> https://drive.google.com/file/d/0B8GFWmLzuj1QT0daNmRfeU5lUWM/view?usp=docslist_api
>>>>> and the dimensions:
>>>>> page.setCropBox(new PDRectangle((float)51.871-10, (float)18.876,
>>>>> (float)293.25+20, (float)36.75));
>>>>>
>>>>> That file has another error:
>>>> Caused by: java.lang.IllegalArgumentException: Dimensions (width=99999
>>>> height=99999) are too large
>>>> org.apache.pdfbox.rendering.TilingPaint.getImage(TilingPaint.java:138)
>>>> org.apache.pdfbox.rendering.TilingPaint.<init>(TilingPaint.java:69)
>>>> org.apache.pdfbox.rendering.PageDrawer.getPaint(PageDrawer.java:263)
>>>>
>>>>
>>>> org.apache.pdfbox.rendering.PageDrawer.getNonStrokingPaint(PageDrawer.java:599)
>>>> org.apache.pdfbox.rendering.PageDrawer.fillPath(PageDrawer.java:675)
>>>>
>>>>
>>>> org.apache.pdfbox.contentstream.operator.graphics.FillNonZeroRule.process(FillNonZeroRule.java:36)
>>>>
>>>>
>>>> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:829)
>>>>
>>>>
>>>> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:485)
>>>>
>>>>
>>>> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:453)
>>>>
>>>>
>>>> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:156)
>>>> org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:196)
>>>> org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:145)
>>>> org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:68)
>>>>
>>>>
>>>> org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.doInBackground(PagePane.java:238)
>>>>
>>>>
>>>> org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.doInBackground(PagePane.java:219)
>>>>       java.lang.Thread.run(Thread.java:745)
>>>>
>>>>
>>>> The file has three patterns with XStep and YStep = 99999. That's too big
>>>> for us.
>>>>
>>>> Tilman
>>>>
>>>>
>>>>
>>>>
>>>> 2016-08-01 15:41 GMT-03:00 John Hewson <john@jahewson.com>:
>>>>> On 1 Aug 2016, at 11:37, Rafael Pivetta Balbuena <
>>>>>
>>>>>> rafael.pivetta@gmail.com> wrote:
>>>>>>
>>>>>> I "cropped" barcode (
>>>>>>>
>>>>>>>
>>>>>> https://drive.google.com/file/d/0B8GFWmLzuj1QV0ZNZ3VyaEkxc1E/view?usp=docslist_api
>>>>>> )
>>>>>>
>>>>>> from a PDF file using PDRectangle.
>>>>>>> This might seems like an obvious question, but do you get the
same
>>>>>> error
>>>>>> with that PDF file
>>>>>> if you don’t do the cropping?
>>>>>>
>>>>>> Also, what were the original crop box dimensions?
>>>>>>
>>>>>> — John
>>>>>>
>>>>>> ...
>>>>>>
>>>>>>>       PDRectangle cropbBox = page.getCropBox();
>>>>>>>       page.setCropBox(new PDRectangle((float)51.871-10, (float)18.876,
>>>>>>> (float)293.25+20, (float)36.75));
>>>>>>>       doc.save("/dirXYZ/testcrop.pdf");
>>>>>>>       doc.close();
>>>>>>> ...
>>>>>>> But in line 'pdfRenderer.renderImageWithDPI(i, 200, ImageType.RGB)'
>>>>>>> PDFRenderer pdfRenderer = new PDFRenderer(document);
>>>>>>>       for (int i = 0; i < document.getNumberOfPages(); ++i)
>>>>>>>       {
>>>>>>>           BufferedImage bim = pdfRenderer.renderImageWithDPI(i,
200,
>>>>>>> ImageType.RGB);
>>>>>>>
>>>>>>>           // suffix in filename will be used as the file format
>>>>>>>           ImageIOUtil.writeImage(bim,
>>>>>>> "/home/pivetta/desenvolvimento/pdf_to_png/testepdfbox/testecrop"
+
>>>>>>> "-" +
>>>>>>> (i+1) + ".png", 600);
>>>>>>>       }
>>>>>>> throws NegativeAtiveArraySizeException. I'm using PDFBOX 2.0.2,
java
>>>>>>> 8,
>>>>>>> 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:529)
>>>>>>
>>>>>>       at
>>>>>>> org.apache.pdfbox.rendering.PageDrawer.fillPath(PageDrawer.java:600)
>>>>>>       at
>>>>>>>
>>>>>>>
>>>>>> org.apache.pdfbox.contentstream.operator.graphics.FillNonZeroRule.process(FillNonZeroRule.java:36)
>>>>>>
>>>>>>       at
>>>>>>>
>>>>>>>
>>>>>> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:815)
>>>>>>
>>>>>>       at
>>>>>>>
>>>>>>>
>>>>>> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:472)
>>>>>>
>>>>>>       at
>>>>>>>
>>>>>>>
>>>>>> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:446)
>>>>>>
>>>>>>       at
>>>>>>>
>>>>>>>
>>>>>> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
>>>>>>
>>>>>>       at
>>>>>>> org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:189)
>>>>>>       at
>>>>>>> org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:208)
>>>>>>>       at
>>>>>>>
>>>>>>>
>>>>>>> org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:139)
>>>>>>>       at
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:94)
>>>>>>
>>>>>>       at ExtractImagesFromPDF.main(ExtractImagesFromPDF.java:67)
>>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>


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


Mime
View raw message