I am using iText to generate a multiple-page PDF file. Now when I execute my program, sometimes the PDF file is generated correctly, but at times I get the following error: "The PDF file is damaged and could not be repaired", when I try to display the file on the browser. If I try to launch it myself from Windows Explorer, it opens up often, but this is also not happening all the time.
I am not able to figure out the exact source of this error.
Any pointers in this direction would be appreciated.