|
Hello, I am generating pdf using itext from a db source through a servlet on weblogic6.1 and displays the pdf back in a webpage. The input for generating the pdf are just a bunch of user selected filters on a webpage.
I encountered a very strange bug: java.lang.OutOfMemoryError <<no stack trace available>>. I know this error occurs when generating large pdfs but that is not the case.
The servlet calls a bunch of stored procs in the db and add the resultsets from them to a itext Table. Now for example, with input1 it generates a 150+ page of pdf perfectly, then I changed the filter to input2 and i get an out of memory error. However input two only suppose to generate like 20 pages and I verified both the stored proc and java sql codes. The program runs until doc.add(datatable) then i get the out of memory error. My itext table contains 16 columns with 3 of them containing large amount of text (Text column datatype used in DB).
After some testing I noticed:
This is the header of my table:
/*********** If I comment out the addCell(title) codes, everything works****
************ If I dont, i get out of memory error in certain inputs *******/ datatable.addCell(new Phrase("title1", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLD))); datatable.addCell(new Phrase("title2", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLD))); datatable.addCell(new Phrase("title3", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLD))); datatable.addCell(new Phrase("title4" FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLD))); ........etc datatable.addCell(new Phrase("title16", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLD))); /**********************************************************************************/ Cell spacer = new Cell(new Phrase(" ", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 5, Font.BOLD)));
spacer.setBorder(Rectangle.NO_BORDER); spacer.setColspan(NumCol); /*********** If I comment out the addCell(spacer) code, everything works**** ************ If I dont, i get out of memory error in certain inputs *******/ datatable.addCell(spacer); datatable.endHeaders(); so basically if i comment out either the header name or the spacer, everything works fine. If i leave them both in, i get out of memory errors. Why is this happening? The total length of the pdf report is only 20ish pages how is an extra row of blank space causing it to go out of memory? especially since it can generate pdf with 150+ pages with no problem whatsoever. Please help, I cant seem to find any solution to this. Also in general what causes out of memory errors other than just a really large pdf.
Thank you,
|
