Hi there, I'm having some issues with the amount of memory PDF generation is using, and I'd just like to run it past you to see if you have any ideas as to the best way to tackle it!
I'm running this as part of a tomcat application. I'm using the following code to open up the file and write the data: Document document = new Document(); PdfWriter writer = PdfWriter.getInstance( document, new FileOutputStream( temporaryFileName )); document.open(); // Add a title page first. .. // Add main pages. PdfPTable table = getPDFRendering(); document.add( table ); document.close(); getPDFRendering() is generating a few nested PdfPTables with the occassionally text Chunk, with a large PdfPTable at its core. This data table contains 500-1000 rows of ~30 columns (each cell containing, typically, an integer). I am also using an extra empty cell between each cell for spacing (I am reusing my 'blank cell' object for each of these empty cells). while watching 'top' when the 'document.add' line gets executed, the memory usage of tomcat increases by ~500mb. There are a few points I thought of: - That's alot of data. However, I'd like to find ways of being able to generate the PDF while trying to control the memory usage. - Extra empty cell for spacing might be a bit retarded, is there some 'cell padding' i can add to the PdfPTable? - Is there something odd adding to the overhead? E.g. having a large table inside a bunch of nested tables? - Would it be better on memory to, instead of creating the table and then adding it to the document, pass the document into the method that generates the main table and do the following: document.add( table ); ... for( int i=0; i<rows; i++ ) { for( int j=0; j<cells_in_row; j++ ) { table.addCell( blah ); } } ... Would any of these ideas help substantially? Is there anything else I can try? Thanks for your help, Sam. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/