Hi Steve, Thanks for your quick reply. I took your suggestion and this is what I found.
Writing the large table out in smaller chunks does indeed solve the OutOfMemory problem. However, it still takes the same amount of time or even more when I split the large table into multiple smaller ones. I am using the code below to do the comparison. The result is quite consistent. Are there any suggestions as to how I can get around this problem? Thanks again shangshin ---------------------------------------------------------------- import com.lowagie.text.*; import com.lowagie.text.Font; import com.lowagie.text.pdf.PdfWriter; import com.lowagie.text.pdf.MultiColumnText; import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfPCell; import java.io.OutputStream; import java.io.FileOutputStream; import java.io.FileNotFoundException; import java.awt.*; public class ExampleLargeTable { private static final int FRAGMENT_SIZE = 50; public static void main(String[] args) { try { Document document = new Document(PageSize.LETTER); OutputStream out = new FileOutputStream("ExampleLargeTable.pdf"); PdfWriter.getInstance(document, out); document.open(); Font font = FontFactory.getFont("Helvetica", 8, Font.BOLD, Color.BLACK); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100f); PdfPCell h1 = new PdfPCell(new Paragraph("Header 1", font)); PdfPCell h2 = new PdfPCell(new Paragraph("Header 2", font)); PdfPCell h3 = new PdfPCell(new Paragraph("Header 3", font)); PdfPCell h4 = new PdfPCell(new Paragraph("Header 4", font)); PdfPCell h5 = new PdfPCell(new Paragraph("Header 5", font)); table.setHeaderRows(1); table.addCell(h1); table.addCell(h2); for (int row=1; row <= 15000; row++) { /*** BEGIN Comment out this section to add the large table into the pdf document at one time ***/ if (row % FRAGMENT_SIZE == FRAGMENT_SIZE-1 ) { document.add(table); table.deleteBodyRows(); table.setSkipFirstHeader(true); } /*** END Comment out this section to add the large table into the pdf document at one time ***/ makeNewRow(table, row, font); } document.add(table); document.close(); } catch (DocumentException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } } private static void makeNewRow(PdfPTable table, int row, Font font) { PdfPCell cell; cell = new PdfPCell(new Paragraph(String.valueOf(row), font)); table.addCell(cell); cell = new PdfPCell(new Paragraph(String.valueOf(row), font)); table.addCell(cell); cell = new PdfPCell(new Paragraph(String.valueOf(row), font)); table.addCell(cell); cell = new PdfPCell(new Paragraph(String.valueOf(row), font)); table.addCell(cell); cell = new PdfPCell(new Paragraph("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla mauris nibh, ultricies nec, adipiscing eget.", font)) ; table.addCell(cell); } } -----Original Message----- From: Steve Appling [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 05, 2005 6:50 AM To: Liao, Shangshin; itext-questions@lists.sourceforge.net Subject: Re: [iText-questions] Performance Issue on Document.add() function Well - try not to make the table so big :) Seriously, you can get the exact same effect as a big table by using multiple smaller tables with the right options. See the example "ExampleLargeTable.java" in the bundle examples-147.zip at itextpdf.sf.net. ----- Original Message ----- From: "Liao, Shangshin" <[EMAIL PROTECTED]> To: <itext-questions@lists.sourceforge.net> Cc: "Liao, Shangshin" <[EMAIL PROTECTED]> Sent: Tuesday, January 04, 2005 6:37 PM Subject: [iText-questions] Performance Issue on Document.add() function Hi, The function in question takes at least 10 seconds if the size of bigTable is more than 1 mega.( plz see sample code below) com.lowagie.text.Document pdfDocument = new com.lowagie.text.Document(PageSize.LETTER.rotate()); PdfPTable bigTable = new PdfPTable(10); pdfDocument.add ( bigTable ); My computer has a 3G cpu and 1G memory. I am wondering if there is a way for optimization. Thanks Shangshin Liao [EMAIL PROTECTED] ------------------------------------------------------------------------ ------ This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. ------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions ------------------------------------------------------------------------------ This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. ------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions