Free the reader after addTemplate and not before but if you
used PdfCopy and it still throws an exception it won't be enough. The size of
the pdf doesn't matter, rather the number of pages. You probably need to throw
more memory at it.
Best Regards,
Paulo Soares
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Toula
Sent: Thursday, April 22, 2004 3:43 PM
To: [EMAIL PROTECTED]
Subject: [iText-questions] OutOfMemoryError when concatenating large PDF
Hi everyone,
I’m trying to create a single PDF file by concatenating multiple single pages PDF. Each single page PDF is about 6 MO.
I use the code below:
pdfr=new PdfReader(loc);
if(pdfr.getNumberOfPages() > 1)
System.out.println("Warning: Multiple page found in this document.\n" +
"\tWill only take the first one !");
PdfImportedPage page= this.doc.getPdfWriter().getImportedPage(pdfr, 1); //this.doc is a PdfContentByte
this.doc.getPdfWriter().freeReader(pdfr);
this.doc.addTemplate(page, x, y);
page=null;
pdfr=null;
this.doc.getPdfWriter().flush();
System.gc();
Is there something I can do to reduce the memory usage? I’ve tried with a PdfCopy instead of the PdfWriter, but it didn’t help.
Or maybe because of iText limitation the only solution would be to have more RAM (and playing around with the heap size)?
******************************************
Michael TOULA
Software Engineer
Dalim Software GmbH
Strassburger Str. 6
D-77694
Kehl am Rhein
GERMANY
tel: +49 7851 919 652
fax: +49 7851 735 76
web: www.dalim.com
******************************************
SEE US AT DRUPA 2004 - May 6th-19th. Hall 9, Booth B62