GridView1.Columns[0].Visible = false; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Equipment.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); HtmlForm frm = new HtmlForm(); GridView1.Parent.Controls.Add(frm); frm.Attributes["runat"] = "server"; frm.Controls.Add(GridView1); frm.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);//create a document object PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);//get a pdf writer instance pdfDoc.Open();//open the document XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr);//invoke XMLWorkerHelper.getInstance().parseXhtml(writer, document, new FileInputStream) pdfDoc.Close();//close the document Response.Write(pdfDoc); Response.End();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)