string attachment = "attachment; filename=FormA5.pdf"; HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.AddHeader("content-disposition", attachment); HttpContext.Current.Response.ContentType = "application/pdf"; StringWriter stw = new StringWriter(); HtmlTextWriter htextw = new HtmlTextWriter(stw); Document doc = new Document(iTextSharp.text.PageSize.A4, 30, 30, 50, 50); //string path = Server.MapPath("PDFs"); PdfWriter.GetInstance(doc, HttpContext.Current.Response.OutputStream); DataTable dt = emp.SelectEmployeeWithDesgnDeptLocComp(empid); doc.Open(); Paragraph paragraphheader = new Paragraph(); paragraphheader.SpacingAfter = 1f; float[] headercols = { 1f, 2f, 1.2f, 2f }; PdfPTable table = new PdfPTable(headercols); table.WidthPercentage = 100f; PdfPCell cell = GetFormName(company); StringReader str = new StringReader(stw.ToString()); HTMLWorker htmlworker = new HTMLWorker(doc); htmlworker.Parse(str); doc.Close(); HttpContext.Current.Response.Write(doc); HttpContext.Current.Response.End(); //Data = Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
Response.End
HttpContext.Current.ApplicationInstance.CompleteRequest
Application_EndRequest
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)