我已經使用了以下參考HTMLParser的沒有工作
using System;
using System.Collections;
using System.Configuration;
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Specialized;
using System.Text;
using System.Data.SqlClient;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
這裏是代碼:
protected void ExportToPDFClick(object sender, EventArgs e)
{
Response.Clear();
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter htw = new HtmlTextWriter(sw);
gvCustomers.RenderControl(htw);
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename=MypdfFile.pdf");
Document document = new Document();
PdfWriter.GetInstance(document, Response.OutputStream);
document.Open();
string html = sb.ToString();
XmlTextReader reader = new XmlTextReader(new StringReader(html));
HtmlParser.Parse(document, reader); //did'nt work, line shows error tells missing reference
document.Close();
sw.Close();
Response.Flush();
Response.End();
}
看到評論,其中錯誤顯示。我錯過了什麼?還是有其他的選擇?該did'nt工作的說法是:
HtmlParser.Parse(document,reader);
itextSharp已更改命名空間,試試這個'iTextSharp.text.html.simpleparser.HTMLWorker.Parse(文檔閱讀器);' – Webruster