Writing a GridView to a .pdf file

I am trying to write a gridview, gv to a .pdf file.

Problems with pdfDoc.

Response.ContentType = "application/pdf" Response.AddHeader("content-disposition", "attachment;filename=Export.pdf") Response.Cache.SetCacheability(HttpCacheability.NoCache) Dim sw As New StringWriter() Dim hw As New HtmlTextWriter(sw) Dim frm As New HtmlForm() gv.Parent.Controls.Add(frm) frm.Attributes("runat") = "server" frm.Controls.Add(gv) frm.RenderControl(hw) Dim sr As New StringReader(sw.ToString()) Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 0.0F) Dim htmlparser As New HTMLWorker(pdfDoc) PdfWriter.GetInstance(pdfDoc, Response.OutputStream) pdfDoc.Open() htmlparser.Parse(sr) pdfDoc.Close() Response.Write(pdfDoc) Response.[End]() 
0
pdf gridview itextsharp
May 27 '14 at 20:02
source share
1 answer

Why don't you loop into Gridview strings or your data sources and create an html string?

0
May 27 '14 at 22:40
source share



All Articles