pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Lehmkuehler <andr...@lehmi.de>
Subject Re: convertToImage -> OutOfMemoryError
Date Thu, 06 Jan 2011 07:19:04 GMT
Hi,

Am 05.01.2011 18:25, schrieb spring@gmx.eu:
>> 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);
>> }
>
> OK, I got it. When the page is to big (e.g. really large images) then an
> OMME is thrown.
> Is there any possiblity to find out the approx. size of the page without
> converting it into an image and catching the OOME?
The final image size depends on the page size and the given resolution. I guess 
the origin size of the tiffs is probably the show stopper.
If you are just interested in the images, try to extract them using 
ExtractImages, see [1] for further information.

BR
Andreas Lehmkühler

http://svn.apache.org/repos/asf//pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/ExtractImages.java

Mime
View raw message