有时我们需要设置中文字体为宋体,西文字体为Times New Roman,对于这种情况,在Spire.Doc中可以如下处理
private void AddTextRange(Section section, Paragraph pragraph, string word, float fontSize, bool isBold, HorizontalAlignment alignType,float suojin)
{
TextRange textRange = pragraph.AppendText(word);
textRange.CharacterFormat.FontSize = fontSize;
textRange.CharacterFormat.Bold = isBold;
//中文字体
textRange.CharacterFormat.FontNameFarEast = "宋体";
//西文字体
textRange.CharacterFormat.FontNameNonFarEast = "Times New Roman";
pragraph.Format.HorizontalAlignment = alignType;
//缩进
pragraph.Format.FirstLineIndent = suojin;
}