Hi All,
I'm generating pdf using itextsharp. for pages upto 100, it is downloading. But for pages more than 100, It is giving me outOfMemory Exception 'Insufficient memory to continue the execution of the program.' Please provide me solution for the problem:
I'm inserting my data in PdfPTable. Here is my code in short:
pdfPage page = new pdfPage();
string attachment = "attachment; filename=" + PDF_Name + ".pdf";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/pdf";
iTextSharp.text.Document doc = new iTextSharp.text.Document();
PdfWriter writer = PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Open();
for (int i = 0; i < dt.Rows.Count; i++)
{
PdfPTable tablePage1 = new PdfPTable(2);
.
.
.
.
.
doc.Add(tablePage1);
if (i != (dt.Rows.Count - 1))
doc.NewPage();
writer.PageEvent = page;
}
doc.Close();
Response.Write(doc);
pdfPage is my class for applying header and footer to every page of pdf.
please provide me solution.
Thanx in advance,