Spire.Doc——中英文字体设置

有时我们需要设置中文字体为宋体,西文字体为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;
}
posted @ 2020-06-08 11:33  gisliuliang  阅读(3069)  评论(0编辑  收藏  举报