1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| 'Export en PDF
Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As EventArgs)
Response.ContentType ="application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=suivi_livraison.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
GridView1.AllowPaging =False
GridView1.DataBind()
GridView1.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim exportpdf As New Document(PageSize.A4.Rotate)
Dim htmlparser As New iTextSharp.text.html.simpleparser.HTMLWorker(exportpdf)
PdfWriter.GetInstance(exportpdf, Response.OutputStream)
exportpdf.AddTitle("test")
exportpdf.AddCreationDate()
exportpdf.Open()
htmlparser.Parse(sr)
exportpdf.Close()
Response.Write(exportpdf)
Response.End() |