pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rafael Pivetta Balbuena <rafael.pive...@gmail.com>
Subject Re: [PDFBox 2.0.2] PDFRenderer.renderImageWithDPI throws java.lang.NegativeArraySizeException
Date Mon, 01 Aug 2016 18:55:38 GMT
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));

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
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message