Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=" + filename + .pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); HtmlForm frm = new HtmlForm(); form1.Parent.Controls.Add(frm); frm.Attributes["runat"] = "server"; frm.Controls.Add(tbl_Graph); frm.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); CreatePages(pdfDoc, writer); pdfDoc.Close(); Response.Write(pdfDoc); Response.End();
System.IO.File.WriteAllText(@"C:\Path\file.pdf", stringwriter.ToString());
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)