Я уже импортировал следующее пространство имен на своей странице asp.net
Импорт iTextSharp
Импорт iTextSharp.text
Импорт iTextSharp.text.pdf
Импорт iTextSharp.text.html
но все равно получена ошибка 'HtmlParser' не объявляется при компиляции, в чем проблема?
Спасибо
Protected Sub btn_print_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_print.Click
'Get the HTML from GridView1
Dim sw As New IO.StringWriter()
Dim htw As New HtmlTextWriter(sw)
Gridview1.RenderControl(htw)
Dim html As String = "<html><body>" + sw.ToString() + "</body></html>"
Dim filename As String = "Temp"
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;FileName=" + filename + ".pdf")
'Set up the response
Response.Clear()
Response.ContentType = "application/pdf"
'Create pdf document
Dim document As New iTextSharp.text.Document(PageSize.A4, 80, 50, 30, 65)
'Create pdf writer, output directly to OutputStream
Dim writer As iTextSharp.text.pdf.PdfWriter = PdfWriter.GetInstance(document, Response.OutputStream)
document.Open()
'Create tempfile to hold the HTML:
Dim tempFile As String = Path.GetTempFileName()
Using tempwriter As New IO.StreamWriter(tempFile, False)
tempwriter.Write(html)
End Using
'Parse the HTML into the document
HtmlParser.Parse(document, tempFile)
'Cleanup
document.Close()
writer.Close()
'Delete the tempfile:
File.Delete(tempFile)
writer = Nothing
document = Nothing
Response.[End]()
End Sub