我想在PDF中显示一个汉字和英文字符。目前中文字符没有以PDF格式显示。我使用了itextsharp来生成带有内容的pdf。我尝试了一些中文字体但没有工作。如何使用itextsharp在PDF中显示汉字和英文字符?
var docIndex = new Document(new Rectangle(792, 612));
var writer = PdfWriter.GetInstance(docIndex, new FileStream(Server.MapPath("~") + "/pdf/Project-" + report.pulledId + currentTime + ".pdf", FileMode.Create));
docIndex.Open();
FontFactory.Register("c:/windows/fonts/msmincho.ttc");
StyleSheet style = new StyleSheet();
style.LoadTagStyle("body", "face", "songti");
style.LoadTagStyle("body", "encoding", BaseFont.IDENTITY_H);
foreach (var elementIndex in HTMLWorker.ParseToList(
new StringReader(sbsample.ToString()), style))
{
docIndex.Add(elementIndex);
}
docIndex.Close();