I have the following code to export a gridview to pdf:
However, I am getting the following error on my codebehind.
HtmlParser not declared.
I am importing the following namespaces:
Any idea why I am getting this error?
Code:
Protected Sub ExportToPDF_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExportToPDF.Click
Response.Clear()
Dim sb As New StringBuilder()
Dim sw As New StringWriter(sb)
Dim htw As New HtmlTextWriter(sw)
grdMyStock.RenderControl(htw)
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment; filename=MypdfFile.pdf")
Dim document As New iTextSharp.text.Document()
PdfWriter.GetInstance(document, Response.OutputStream)
document.Open()
Dim html As String = sb.ToString()
Dim reader As New XmlTextReader(New StringReader(html))
HtmlParser.Parse(document, reader)
document.Close()
sw.Close()
Response.Flush()
Response.[End]()
End Sub
However, I am getting the following error on my codebehind.
HtmlParser not declared.
I am importing the following namespaces:
Code:
Imports System.IO
Imports System.Xml
Imports System.Drawing
Imports iTextSharp.text.pdf
Imports iTextSharp
Imports iTextSharp.text
Imports iTextSharp.text.html
Imports System.Web.UI.HtmlControls
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Data.SqlClient
Imports System.Collections.Generic
Imports System.Text
Imports System.Reflection
Any idea why I am getting this error?