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