我使用來自其他question代碼和我正的誤差作爲錯誤而使用iTextSharp的
錯誤1所述的非通用型 「iTextSharp.text.List」不能使用 與類型參數
錯誤2名稱「HTMLWorker」不 在當前上下文中存在
錯誤3類型或命名空間名稱 「HTMLWorker」找不到(是 你缺少using指令或 集引用)
到目前爲止我的代碼如下:?
protected void Button2_Click(object sender, EventArgs e)
{
//Extract data from Page (pd).
Label16.Text = Editor1.Content; // Attribute
// makae ready HttpContext
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/pdf";
// Create PDF document
Document pdfDocument = new Document(PageSize.A4, 80, 50, 30, 65);
//PdfWriter pw = PdfWriter.GetInstance(pdfDocument, HttpContext.Current.Response.OutputStream);
PdfWriter.GetInstance(pdfDocument, HttpContext.Current.Response.OutputStream);
pdfDocument.Open();
//WebClient wc = new WebClient();
string htmlText = Editor1.Content;
List<IElement> htmlarraylist = HTMLWorker.ParseToList(new StringReader(htmlText), null);
for (int k = 0; k < htmlarraylist.Count; k++)
{
pdfDocument.Add((IElement)htmlarraylist[k]);
}
//pdfDocument.Add(new Paragraph(IElement));
pdfDocument.Close();
HttpContext.Current.Response.End();
}
請幫我解決這個錯誤。我正在嘗試從htmleditor獲取內容(非html)並顯示在pdf文件中。請確認我所做的是否正確。
什麼是HTMLWorker導入? – Ishan 2010-11-26 10:54:14