So where is the rest of the document's information stored, besides the page tree and xref? I wrote a program that builds a big PDF out of a bunch of small PDFs by using a PDFCopy writer. After calling writer.AddPage() to append one of the small PDFs, I have a break point in my debugger, and the consolidated file on disk is still 0 kb (and writer.Flush() does not make a difference). Only when I call document.Close(), after appending all the small PDFs, does the consolidated file on disk have any size. This implied to me that the consolidated document is being held entirely in RAM as I append the pages, but I must be wrong. Can you please clear up my confusion? As a side note, I am using iTextSharp, not iText, but I think they should behave the same.
Thanks. --- Paulo Soares <[EMAIL PROTECTED]> wrote: > Only the xref and the references to the page tree > are kept in memory. You'll > have to call gc before checking memory if you want > to get meaningful > readings. > > ----- Original Message ----- > From: "Jason Frank" <[EMAIL PROTECTED]> > To: <[email protected]> > Sent: Thursday, October 20, 2005 9:51 PM > Subject: [iText-questions] Memory and Concatenating > PDFs > > > > I've done some searching through this mailing list > so I think I know the > answer > > to this question, but I'd like to verify it > because it's not totally clear > to > > me and it will make a big difference as to whether > I think I can use iText > or > > not. > > > > Suppose I am generating a large report (e.g. 3000 > pages). I want to > minimize > > my > > use of server memory (RAM). The report is > composed of many independent > pieces, > > each of which will usually be pretty small. I can > easily see how I can > create > > a > > bunch of small PDF files, one for each piece of > the report, and this will > not > > use much memory at all because I'm always dealing > with one small document > at a > > time. > > > > However, at the end I need to concatenate these > small documents together > into > > one big document (presumably using PdfCopy). My > reading of the various > > postings is that this will be a memory-intensive > process, no matter what I > try > > to do. > > The reason is that you cannot just "append" to a > PDF that exists on disk; > > instead, you have to read in both PDFs to memory > and then concatenate > them. So > > if I'm looping through all the little files and > adding them to the big > document > > that I'm trying to create, by the time I get to > the last little PDF, I now > have > > my full report in memory all at once. In which > case it might be better to > skip > > the part about creating all the little separate > documents, because you > have to > > be able to hold the big document in memory anyway > by the time you've > appended > > all the little ones to create it. > > > > On a related topic, I've done some tests in > creating a big document and > trying > > to periodically use pdfWriter.flush() to get it to > write out a partial > file and > > thus free up some memory, but this doesn't seem to > actually do anything > (the > > file on disk does not change size, nor does my > memory usage go down). > > > > Can someone please verify that I'm understanding > this correctly, or show > me a > > way to do what I want to do without having the big > document in memory? I > have > > seen some statements that it is only the "xrefs" > that need to be in memory > for > > the big document, but I did not know what this > meant. > > > > Thanks > > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: > > Power Architecture Resource Center: Free content, > downloads, discussions, > > and more. > http://solutions.newsforge.com/ibmarch.tmpl > > _______________________________________________ > > iText-questions mailing list > > [email protected] > > > https://lists.sourceforge.net/lists/listinfo/itext-questions > > __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
