翻譯|使用教程|編輯:李顯亮|2021-09-18 09:22:27.740|閱讀 370 次
概述:PowerPoint 提供了廣泛的主題,可以在演示文稿中應用這些主題。此外,可以根據自己的要求定義自己的自定義主題。在本文中,將學習如何動態處理 PowerPoint 演示文稿的主題
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
PowerPoint 提供了廣泛的主題,您可以在演示文稿中應用這些主題。此外,您可以根據自己的要求定義自己的自定義主題。在本文中,您將學習如何動態處理 PowerPoint 演示文稿的主題,特別是,本文將介紹如何使用 C# 以編程方式在 PowerPoint 演示文稿中應用主題。
為了在 PowerPoint 演示文稿中應用主題,我們將使用Aspose.Slides for .NET,它是一個強大且功能豐富的 API,用于在 .NET 應用程序中創建和操作演示文稿。
>>你可以點擊這里下載Aspose.Slides 最新版測試體驗。
PowerPoint 主題表示一組可以應用于不同元素的顏色、字體大小、字體系列、背景樣式等。在以下部分中,我們將明確介紹如何在 PowerPoint 演示文稿中設置主題顏色、字體和背景。
以下是使用 C# 為 PowerPoint 演示文稿中的形狀設置主題顏色的步驟。
以下代碼示例展示了如何使用 C# 在 PowerPoint 演示文稿中設置主題顏色。
// Load or create presentation using (Presentation pres = new Presentation()) { // Add shape and set its color IAutoShape shape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 100, 100); shape.FillFormat.FillType = FillType.Solid; shape.FillFormat.SolidFillColor.SchemeColor = SchemeColor.Accent1; // Save presentation pres.Save("theme.pptx", SaveFormat.Pptx); }
Aspose.Slides 提供了特殊的標識符來設置字體方案中的字體。以下是使用文本創建元素并從字體方案分配拉丁字體的步驟。
以下代碼示例展示了如何使用 C# 在 PowerPoint 演示文稿中設置主題字體。
// Load or create presentation using (Presentation pres = new Presentation()) { // Add shape and set its color IAutoShape shape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 100, 100); // Add paragraph Paragraph paragraph = new Paragraph(); Portion portion = new Portion("Theme text format"); paragraph.Portions.Add(portion); shape.TextFrame.Paragraphs.Add(paragraph); // Set font portion.PortionFormat.LatinFont = new FontData("+mn-lt"); // Save presentation pres.Save("theme.pptx", SaveFormat.Pptx); }
演示文稿主題還包含您可以在 PowerPoint 演示文稿中設置的背景樣式。以下是執行此操作的步驟。
以下代碼示例展示了如何在演示文稿中設置主題背景樣式。
using (Presentation pres = new Presentation()) { // Check number of styles int numberOfBackgroundFills = pres.MasterTheme.FormatScheme.BackgroundFillStyles.Count; if (numberOfBackgroundFills > 0) { // Select a style pres.Masters[0].Background.StyleIndex = 1; } // Save presentation pres.Save("theme.pptx", SaveFormat.Pptx); }
如果你想試用Aspose的全部完整功能,可聯系在線客服獲取30天臨時授權體驗。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn