公共 API 与向后不兼容的更改(Aspose.Slides for .NET 15.1.0)
Contents
[
Hide
]
此页面列出了所有已添加或已移除的类、方法、属性等,以及 Aspose.Slides for .NET 15.1.0 API 所引入的其他更改。
公共 API 更改
已添加字体替换功能
已添加在整个演示文稿中全局替换字体以及在渲染时临时替换字体的功能。
Presentation 类新增了属性 “FontsManager”。FontsManager 类具有以下成员:
IFontSubstRuleCollection FontSubstRuleList 属性
此集合包含 IFontSubstRule 实例,用于在渲染期间替换字体。IFontSubstRule 拥有实现 IFontData 接口的 SourceFont 和 DestFont 属性,以及 ReplaceFontCondition 属性,用于选择替换条件(“WhenInaccessible” 或 “Always”)。
IFontData[] GetFonts() 方法
用于检索当前演示文稿中使用的所有字体。
ReplaceFont 方法
用于在演示文稿中持久替换字体。
以下示例演示如何在演示文稿中替换字体:
Presentation pres = new Presentation("PresContainsArialFont.pptx");
IFontData sourceFont = new FontData("Arial");
IFontData destFont = new FontData("Times New Roman");
pres.FontsManager.ReplaceFont(sourceFont, destFont);
pres.Save("PresContainsTimesNoewRomanFont.pptx", SaveFormat.Pptx);
另一个示例演示在渲染时当字体不可访问时的字体替换:
Presentation pres = new Presentation("PresContainsSomeRareFontFont.pptx");
IFontData sourceFont = new FontData("SomeRareFont");
IFontData destFont = new FontData("Arial");
IFontSubstRule fontSubstRule = new FontSubstRule(
sourceFont, destFont, FontSubstCondition.WhenInaccessible);
IFontSubstRuleCollection fontSubstRuleCollection = new FontSubstRuleCollection();
fontSubstRuleCollection.Add(fontSubstRule);
pres.FontsManager.FontSubstRuleList = fontSubstRuleCollection;
// Arial font will be used instead of SomeRareFont when inaccessible
pres.Slides[0].GetThumbnail();