Hello All,

I'm developing an application that should merge a set of PDF. The
problem is that I get an java.lang.OutOfMemoryError exception. I tried
to increase the max JVM heap size (java -Xmx???), it helps but I think
it isn't a good solution because I do never know how many PDFs are used
and how much memory it needs.

Is it possible I do something wrong? Below is the most important and
"gluttonous" part of my application (I use itext-paulo-129 version).
Thanks.


Document document = null; PdfCopy writer = null; int pageOffset = 0; ArrayList master = new ArrayList(); FileOutputStream os = new FileOutputStream(strOutFile);

for (int i = 0; i < file_list.length; ++i) {
        PdfReader reader = new PdfReader(file_list[i].getName());
        
        int n = reader.getNumberOfPages();
        
        List bookmarks = SimpleBookmark.getBookmark(reader);
        if (bookmarks != null) {
                if (pageOffset != 0)
                        SimpleBookmark.shiftPageNumbers(bookmarks, pageOffset, null);
                master.addAll(bookmarks);
        }
        pageOffset += n;
        
        if (i == 0) {
                document = new
                Document(reader.getPageSizeWithRotation(1));
                writer = new PdfCopy(document, os);
                document.open();
        }

        PdfImportedPage page;
        for (int j = 0; j < n;) {
                ++j;
                page = writer.getImportedPage(reader, j);
                writer.addPage(page);
        }

        PRAcroForm form = reader.getAcroForm();
        if (form != null)
                writer.copyAcroForm(reader);

        writer.flush();
}

if (document != null) {
        if (master.size() > 0)
        writer.setOutlines(master);
        document.close();
}


-- Best regards, Sergey Chumakov 2:450/77[.43]





-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to