问题
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