How to display chinese characters in PDF using ITextSharp in c#?

 ̄綄美尐妖づ 提交于 2019-12-11 06:57:59

问题


I want to display one word of chinese characters in PDF along with english characters. Currently chinese characters are not getting displayed in PDF.I have used itextsharp to generate pdf with contents.I have tried some chinese fonts but not working. How to show chinese characters along with english characters in PDF using itextsharp?

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();

来源:https://stackoverflow.com/questions/47075049/how-to-display-chinese-characters-in-pdf-using-itextsharp-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!