ssinai wrote:
>> Why read the tutorials when I have your book?

;-)

>> Anyway, I'm working on an application where we're trying to convert lots
>> of Swing tables to pdf.  Each table takes up one full page of a pdf
>> document.  For each table, I'm creating a PdfGraphics2D object, and
>> drawing into it along the lines of ...mySwingTable.print(PdfGraphics2D
>> g2).  This seems to be working pretty well as long as we don't have too
>> many tables.  But in one of our use cases, we have over 900 Swing tables
>> that we need to place into a pdf document.

OK.

>> I try to loop through the list of 900 tables and convert each one to a new
>> pdf page in a document.  After about 300 pages, the free memory is
>> exhausted, the pdf processing stops, and the document closes itself.  So
>> we get a document of about 300 pages, which at this point is about 90 Mb.
>> It's readable, but I need all 900 pages. 

Hmm... are you keeping all these pages in memory?
Normally iText has a small memory stamp.

>> I've tried a few things to free up memory during this process, like
>> getting rid of the Swing tables after they've been converted to pdf, and
>> while I've been able to get an extra 10 or so pages generated from doing
>> this, it's not solving the problem.   I was thinking about doing something
>> like opening a document, generating 100 pages of pdf from Swing tables,
>> closing the document in the hope that it would flush everything to disk
>> and free up memory, and then reopening the document to repeat the process
>> until all 900 tables were converted to pdf.  I don't know what's going on
>> with memory as pdf documents are generated, so don't know whether this
>> will work, but I thought it would be worth a try.
>>
>> Any suggestions would be appreciated.  I guess this is basically the same
>> thing as putting 900 large images into a pdf document.   In fact, we're
>> supposed to be able to produce documents consisting of thousands of pages,
>> but if I can do the 900 pages, I'd be happy.  Thanks.

Is it really necessary to create the 900 separate PDF files.
Wouldn't it be a better idea to write the Swing tables to
a PdfTemplate, add the template to a new Page, then make sure
the Swing table and the PdfTemplate are removed from memory.

That seems like a much more elegant solution (less overhead).
br,
Bruno

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to