【发布时间】:2014-11-19 11:24:01
【问题描述】:
我有一个名为:“DocumentContent”的富文本框,我将使用以下代码将其内容添加到 pdf:
iTextSharp.text.Font font = FontFactory.GetFont(@"C:\Windows\Fonts\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 12f, Font.NORMAL, BaseColor.BLACK);
DocumentContent = System.Web.HttpUtility.HtmlDecode(DocumentContent);
Chunk chunkContent = new Chunk(DocumentContent);
chunkContent.Font = font;
Phrase PhraseContent = new Phrase(chunkContent);
PhraseContent.Font = font;
PdfPTable table = new PdfPTable(2);
table.WidthPercentage = 100;
PdfPCell cell;
cell = new PdfPCell(new Phrase(PhraseContent));
cell.Border = Rectangle.NO_BORDER;
table.AddCell(cell);
问题是当我打开 PDF 文件时,内容显示为 HTML 而不是如下文本:
<p>Overview  line1 </p><p>Overview  line2
</p><p>Overview  line3 </p><p>Overview 
line4</p><p>Overview  line4</p><p>Overview 
line5 </p>
但它应该如下所示
Overview line1
Overview line2
Overview line3
Overview line4
Overview line4
Overview line5
我要做的是保留用户对富文本应用的所有样式,并将字体系列更改为 Arial。
我可以更改字体系列,但我需要将此内容从 HTML 解码为文本。
你能建议吗? 谢谢
【问题讨论】:
标签: pdf itextsharp richtext