pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <spr...@gmx.eu>
Subject convertToImage -> OutOfMemoryError
Date Wed, 05 Jan 2011 14:15:35 GMT
Hello,

I convert bigger PDF files (100 pages, each page is a TIFF G4, 6 MB total)
into png-Files:

PDDocument doc = PDDocument.load(new File("big.pdf"));
PDDocumentCatalog catalog = doc.getDocumentCatalog();
List pages = catalog.getAllPages();
for(Object o : pages){
  PDPage page = (PDPage)o;
  BufferedImage image = page.convertToImage();//<= OOME
  ImageIO.write(image, "png", file);
}
 
Do we have a bug here in PDFBox or is my code the problem?

Thank you! 

P.S. I can comment out the line ImageIO.write(image, "png", file); doesn't
matter.
 
 
java.lang.OutOfMemoryError: Java heap space
	at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
	at java.awt.image.Raster.createPackedRaster(Raster.java:458)
	at
java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorMo
del.java:1015)
	at java.awt.image.BufferedImage.<init>(BufferedImage.java:321)
	at
sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:537)
	at
sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:521)
	at sun.java2d.loops.MaskBlit$General.MaskBlit(MaskBlit.java:171)
	at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Blit.java:186)
	at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:927)
	at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:550)
	at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:54)
	at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:982)
	at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:168)
	at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2988)
	at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2973)
	at sun.java2d.pipe.DrawImage.makeBufferedImage(DrawImage.java:317)
	at sun.java2d.pipe.DrawImage.renderImageXform(DrawImage.java:372)
	at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:199)
	at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:1053)
	at
sun.java2d.pipe.ValidatePipe.transformImage(ValidatePipe.java:212)
	at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3110)
	at
org.apache.pdfbox.pdfviewer.PageDrawer.drawImage(PageDrawer.java:385)
	at
org.apache.pdfbox.util.operator.pagedrawer.Invoke.process(Invoke.java:117)
	at
org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:
529)
	at
org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java
:274)
	at
org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java
:251)
	at
org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:22
5)
	at
org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:107)
	at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:722)
	at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:693)
 


Mime
View raw message