【发布时间】:2011-05-16 03:18:18
【问题描述】:
我正在使用来自其他 question 的代码,我收到的错误是
错误 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 文件中。请确认我所做的是否正确。
【问题讨论】:
标签: c# itextsharp