Hi I'm trying to write my datagrid view to a pdf. I have done the following code but it just says the document is empty. Any idea?
Response.ContentType = "application/pdf" Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf") Response.Cache.SetCacheability(HttpCacheability.NoCache) Dim sw As New StringWriter() Dim hw As New HtmlTextWriter(sw) DataGrid1.AllowPaging = False DataGrid1.DataBind() DataGrid1.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()