-
-
Save lucamilan/e5ae7d577423f162712a4069c0143b80 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Response.ContentType = "application/pdf"; | |
| Response.AddHeader("content-disposition", "attachment;filename=Export.pdf"); | |
| Response.Cache.SetCacheability(HttpCacheability.NoCache); | |
| StringWriter sw = new StringWriter(); | |
| HtmlTextWriter hw = new HtmlTextWriter(sw); | |
| HtmlForm frm = new HtmlForm(); | |
| GrdView.Parent.Controls.Add(frm); | |
| frm.Attributes["runat"] = "server"; | |
| frm.Controls.Add(GrdView); | |
| frm.RenderControl(hw); | |
| StringReader sr = new StringReader(sw.ToString()); | |
| Document pdfDoc = new Document(PageSize.A4, 30f, 30f, 20f, 20f); | |
| pdfDoc.SetMargins(40f, 40f, 40f, 40f); | |
| HTMLWorker htmlparser = new HTMLWorker(pdfDoc); | |
| PdfWriter.GetInstance(pdfDoc, Response.OutputStream); | |
| pdfDoc.Open(); | |
| htmlparser.Parse(sr); | |
| pdfDoc.Close(); | |
| Response.Write(pdfDoc); | |
| Response.End(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment