Microsoft PowerPoint文件管理控件Aspose.Slides新功能示例详解——支持字体回退

Aspose.Slides for .NET是独特的演示处理API,使应用程序可以读取,编写,修改和转换PowerPoint演示文稿。做为独立的API,它提供了管理PowerPoint关键功能的功能,例如管理文本,形状,表格和动画,向幻灯片添加音频和视频,预览幻灯片等等。bash

近期,Aspose.Slides for .NET更新至最新版v19.10,如今有一些很是有趣且实用的功能值得为你们讲解一下,好比新增支持字体回退,以及在占位符中设置提示文本,接下来经过一些简单的示例来为你们说明一下!ide

支持字体回退

当遇到的字符不属于任何其余可用字体的组成部分时,将使用后备字体中的符号代替。一般,后备字体将包含表明各类类型的Unicode字符的符号。如今,该支持也已成为Aspose.Slides的一部分。布局

下面的代码示例演示如何使用FontFallBackRule对象设置字体回退。字体

uint startUnicodeIndex = 0x0B80;
            uint endUnicodeIndex = 0x0BFF;

            IFontFallBackRule firstRule = new FontFallBackRule(startUnicodeIndex, endUnicodeIndex, "Vijaya"); IFontFallBackRule secondRule = new FontFallBackRule(0x3040, 0x309F, "MS Mincho, MS Gothic"); //字体列表也能够经过几种方式添加: string[] fontNames = new string[] { "Segoe UI Emoji, Segoe UI Symbol", "Arial" }; IFontFallBackRule thirdRule = new FontFallBackRule(0x1F300, 0x1F64F, fontNames);复制代码

与此相似的基于Java的示例:动画

Presentation presentation = new Presentation();    
try {    
IFontFallBackRulesCollection userRulesList = new FontFallBackRulesCollection();    
userRulesList.add(new FontFallBackRule(0x0B80, 0x0BFF, "Vijaya")); userRulesList.add(new FontFallBackRule(0x3040, 0x309F, "MS Mincho, MS Gothic")); presentation.getFontsManager().setFontFallBackRulesCollection(userRulesList); } finally { if (presentation != null) presentation.dispose(); }复制代码

在占位符中设置提示文本

一个提示文本是当它是第一负载,可是当用户开始输入到该消失出如今文本字段的文本的文本字段。基本上,这是为了使用户易于了解要在所选字段中输入的内容。咱们知道标准布局和预构建布局包含带有默认文本的占位符,如Click添加标题 或 Click添加字幕。使用Aspose.Slides能够经过访问默认占位符来手动添加提示文本。下面的代码段显示了如何使用此功能:ui

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Text();

using (Presentation pres = new Presentation(dataDir + "Presentation2.pptx")) { ISlide slide = pres.Slides[0]; foreach (IShape shape in slide.Slide.Shapes) // iterate through the slide { if (shape.Placeholder != null && shape is AutoShape) { string text = ""; if (shape.Placeholder.Type == PlaceholderType.CenteredTitle) // title - the text is empty, PowerPoint displays "Click to add title". { text = "Click to add custom title"; } else if (shape.Placeholder.Type == PlaceholderType.Subtitle) // the same for subtitle. { text = "Click to add custom subtitle"; } ((IAutoShape)shape).TextFrame.Text = text; Console.WriteLine($"Placeholder with text: {text}"); } } pres.Save(dataDir + "Placeholders_PromptText.pptx", SaveFormat.Pptx); }复制代码

若是您有任何疑问或需求,请随时加入Aspose技术交流群(642018183)!spa

相关文章
相关标签/搜索