C# Itextsharp将html呈现为html源

C# Itextsharp将html呈现为html源,c#,html,asp.net,itextsharp,C#,Html,Asp.net,Itextsharp,我在itextsharp中有以下代码 productCell.AddElement(new Phrase(Server.HtmlDecode((this.Product.Description != null) ? this.Product.Description : ""), "Arial")); 但是页面呈现为html源代码。 有人有解决办法吗? 代码的其余部分很好试试这个。为我工作 FontFactory.RegisterDirectories(); Li

我在itextsharp中有以下代码

productCell.AddElement(new Phrase(Server.HtmlDecode((this.Product.Description != null) ? this.Product.Description : ""), "Arial"));
但是页面呈现为html源代码。 有人有解决办法吗?
代码的其余部分很好

试试这个。为我工作

        FontFactory.RegisterDirectories();
        List<IElement> htmlarraylist = HTMLWorker.ParseToList(new StringReader("<html><head></head><body><div style='font-family: Cambria'>" + text + "</div></body></html>"), null);
        for (int k = 0; k < htmlarraylist.Count; k++)
        {
            cell.AddElement((IElement)htmlarraylist[k]);
        }
       Tbl.AddCell(cell);
FontFactory.RegisterDirectories();
List htmlaraylist=HTMLWorker.parsetList(新的StringReader(“+text+”),null);
for(int k=0;k
只回答字体部分,这样它就可以帮助任何人,使用para插件块并将字体应用到块中

List<IElement> htmlarraylist = HTMLWorker.ParseToList(new StringReader(htmldata), null);
Paragraph pdesc=new Paragraph();
    for (int k = 0; k < htmlarraylist.Count; k++)
    {
        //Applies font to each chunk within para
        foreach (Chunk chunk in htmlarraylist[k].Chunks)
        {
            pdesc.Add(new Chunk(chunk.ToString(),arial));
        }
    }
    yourCellInDocument.AddElement(pdesc);
List htmlaraylist=HTMLWorker.parsetList(新的StringReader(htmldata),null);
段落pdesc=新段落();
for(int k=0;k
您好,谢谢您的回答,这很有效,但我现在如何将字体添加到元素中?将其添加到html中,或尝试将CSS作为ParseToList的第二个参数尝试此“+htmldata+”不工作回答已更新。请参阅此处了解更多适用于我的作品,我已经测试过了。按我添加的方式添加字体,而不是使用+