0
我已經能夠在這裏遵循的例子,已經能夠獲得中國漢字顯示,如果他們是表外,但在一個表中的單元格內他們不會。的PDF顯示中國漢字是從一個HTML表使用iTextSharp的
這是HTML代碼示例 -
@{
<head>
<title>Daily Production Report 國務院公佈了房</title>
</head>
}
@{
<table style="width: 61%; font-size:x-small; font-family:'Arial Unicode MS'" border="1">
<tr>
<td style="width: 78px">Date:</td>
<td style="width: 200px"> </td>
<td style="width: 80px">Order ID</td>
<td style="width: 200px">國務院公佈了房</td>
<td style="width: 112px">Total Pieces</td>
<td style="width: 200px"> </td>
</tr>
</table>
}
這是後面的代碼 -
FontFactory.Register("c:/windows/fonts/ARIALUNI.TTF");
StyleSheet style = new StyleSheet();
style.LoadTagStyle("body", "face", "Arial Unicode MS");
style.LoadTagStyle("body", "encoding", BaseFont.IDENTITY_H);
using (Document document = new Document())
{
PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create));
document.Open();
foreach (IElement element in HTMLWorker.ParseToList(
new StringReader(HTMLData.ToString()), style))
{
document.Add(element);
}
document.Close();
}
工作很好!謝謝...我如何將我的代碼更改爲使用XMLWorker? – Craig
'XMLWorker'是一個單獨的二進制文件,你可以在這裏找到最新的:http://sourceforge.net/projects/itextsharp/files/xmlworker/。然而,這不是直接升級。這裏有幾個帖子展示了使用它的例子。 http://stackoverflow.com/a/21165654/231316 http://stackoverflow.com/a/16105368/231316 http://stackoverflow.com/a/15362705/231316 –