我正在尝试将字体从Arial更改为默认字体Times New Roman . 我尝试了不同的解决方案,但没有一个帮助!

原始代码是:

PdfWriter writer = PdfWriter.GetInstance(doc, file);
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
writer.SetEncryption();
doc.Open();
FontFactory.Register(
    "C:\\Windows\\Fonts\\ARIALUNI.TTF", "arial unicode ms");
iTextSharp.text.html.simpleparser.StyleSheet ST =
    new iTextSharp.text.html.simpleparser.StyleSheet();
ST.LoadTagStyle("body", "encoding", "Identity-H"); `

我正在为Times New Roman测试这段代码:

FontFactory.Register(
     "C:\\Windows\\Fonts\\Times New Roman\\times.tff",
     "times new roman regular");
iTextSharp.text.html.simpleparser.StyleSheet ST =
    new iTextSharp.text.html.simpleparser.StyleSheet();
ST.LoadTagStyle("body", "face", "times new roman");
ST.LoadTagStyle("body", "encoding", "Identity-H");