Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iTextSharp error

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
I have the following code to export a gridview to pdf:
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?
 
What line of code thows the error?
If it has to do with iTextSharp, you will have to contact them.
 
The line of code is
Code:
HtmlParser.Parse(document, reader)
 
The error is specific to that vendor's object. You should go to their website and/or forums. While searching I found some imports that another person used, you may need to add somehting:
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
using System.IO;
using System.Collections;
using System.Net;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top