agreed....
 
I'm concatenating about 40K PDFs resulting in a PDF under 100MB and 100K+ pages 
(with 300DPI images...god love PdfSmartCopy) and it runs in a few minutes and 
without any JVM tweaks.
 
copy.freeReader( reader ) is definately the way to go.
 
Jason

________________________________

From: Mark Storer [mailto:msto...@autonomy.com]
Sent: Wed 11/10/2010 12:05 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Out Of Memory Error Concatenating 
MultiplePDFFiles


Ah!
 
While you could save the PDF to a file rather than a BAOS, the big savings will 
be in calling copy.freeReader(reader) when you're done with each reader in turn:
 
for (int x = 0; x < PdfReaderArray.length; x++) {
    reader = PdfReaderArray[x];
 
    for (int page = 0; page < reader.getNumberOfPages(); ) {
      copy.addPage(copy.getImportedPage(reader, ++page);
    }
    copy.freeReader(reader);
 
}
 
Otherwise you're keeping everything from each reader in memory until you 
"copy.close()".
 
--Mark Storer
  Senior Software Engineer
  Cardiff.com
 
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
 
 


________________________________

        From: McGee, Ed F, CTR, OSD-CAPE [mailto:edwin.mcgee....@osd.mil] 
        Sent: Tuesday, November 09, 2010 2:55 PM
        To: 'itext-questions@lists.sourceforge.net'
        Subject: [iText-questions] Out Of Memory Error Concatenating Multiple 
PDFFiles
        
        
        
        Is there a size limitation to a PdfCopy object and/or PdfSmartCopy 
object?  I have tried both, as suggested in iText in Action, second edition, 
but get the same error.
         
        I am concatenating multiple PDF files and I am now encountering an 
Out-Of-Memory error as I import pages using code similar to the following:
         
        I have an input of PdfReader[] which contains 16 PdfReader objects with 
approximately 457 pages when combined.
         
        Document document = new Document();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfCopy copy = new PdfCopy(document, baos);
        document.open();
         
        PdfReader reader = null;
         
        for (int x = 0; x < PdfReaderArray.length; x++) {
            reader = PdfReaderArray[x];
         
            for (int page = 0; page < reader.getNumberOfPages(); ) {
              copy.addPage(copy.getImportedPage(reader, ++page);
            }
         
        }
         
        Any assistance is appreciated.
         
         



***This is a transmission from Purdue Employees Federal Credit
Union (PEFCU) and is intended solely for its authorized
recipient(s), and may contain information that is confidential
and or legally privileged.  If you are not an addressee, or the
employee or agent responsible for delivering it to an addressee,
you are hereby notified that any use, dissemination,
distribution, publication or copying of the information 
contained
in this email is strictly prohibited. If you have received this
transmission in error, please notify us by telephoning (765)
497-3328 or returning the email. You are then instructed to
delete the information from your computer.  Thank you for your
cooperation.***

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to