download multiple pdf

naguini

New Member
I am trying to download multiple pdf's as attachments in my asp.net application.I have created some templates and filling values using pdfstamper(itextsharp). I am able to fill the values but not able to download. \[code\]private void FillForm(string path, DataTable BridgeValues, DataTable Comments, DataTable Maintenance,string Newfilename) { try { string pdfTemplate = path; string newFile = Newfilename; string Pathser = ""; if (!System.IO.Directory.Exists(Server.MapPath(@"~/PDF/"))) { System.IO.Directory.CreateDirectory(Server.MapPath(@"~/PDF/")); } if (Directory.Exists(Server.MapPath(@"~/PDF/"))) { Pathser = Server.MapPath(@"~/PDF/" + Newfilename); } System.IO.MemoryStream mStream = new System.IO.MemoryStream(); // create a new PDF reader based on the PDF template document PdfReader pdfReader = new PdfReader(pdfTemplate); PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(Pathser, FileMode.Create)); AcroFields pdfFormFields = pdfStamper.AcroFields; DataColumn dc = null; for (int i = 0; i < BridgeValues.Columns.Count - 1; i++) { dc = BridgeValues.Columns; pdfFormFields.SetField(dc.ColumnName.ToString(), BridgeValues.Rows[0][dc].ToString()); } pdfStamper.FormFlattening = true; // close the pdf pdfStamper.Close(); ////Response.ContentType = "application/octet-stream"; Response.ContentType = "application/pdf"; ////Response.AddHeader("Content-Disposition", "attachment; filename=Report.pdf"); Response.AddHeader("Content-Disposition", "attachment; filename=" + Newfilename + ""); ////Response.BinaryWrite(mStream.ToArray()); Response.TransmitFile(Server.MapPath(("~/PDF/"+ Newfilename))); Response.Clear(); Response.End(); } catch (System.Threading.ThreadAbortException lException) { // do nothing } }\[/code\]First time I tried to create one pdf ,it worked but later when I tried to download multiple files it gave an execption.Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
 
Top