原創|行業資訊|編輯:李顯亮|2019-09-02 14:43:36.397|閱讀 220 次
概述:Aspose.Slides for .NET是獨特的演示處理API,使應用程序能夠讀取,編寫,修改和轉換PowerPoint演示文稿。Aspose.Slides for .NET更新至最新版v19.8,引入了用于獲得有效值的新API,從而獲取“本地”值和“有效”值。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.Slides for .NET是獨特的演示處理API,使應用程序能夠讀取,編寫,修改和轉換PowerPoint演示文稿。作為獨立的API,它提供了管理PowerPoint關鍵功能的功能,例如管理文本,形狀,表格和動畫,向幻燈片添加音頻和視頻,預覽幻燈片等等。
Aspose.Slides for .NET更新至最新版v19.8,引入了用于獲得有效值的新API,從而獲取“本地”值和“有效”值。下面我們一起來了解一下具體內容吧!>>歡迎下載Aspose.Slides for .NET v19.8體驗
新的功能支持通過IPortion.PortionFormat在不同級別的表示結構層次結構中設置文本部分的屬性。以下是其中一些:
對于任何這些級別,直接在此級別設置的值稱為“本地”。在任何級別,可以定義或省略“本地”值。但最后,當應用程序(使用Aspose.Slides甚至PowerPoint本身構建)需要知道該部分應該是什么樣的時候(在圖像導出或在屏幕上繪圖時),它使用“有效”值 - 完全使用層次結構構建的已定義值集,可能的值覆蓋最低層的每個級別以及硬編碼到PowerPoint中的默認值。
“有效數據”對象本質上是不可變的-它們僅用于獲取最終的組合信息。“本地數據“”對象是可變的-它們用于設置屬性。
啟動Aspose.Slides v19.8所需要的只是從您希望獲得有效值的本地格式調用GetEffective()方法。下面列舉個例子說明:
using (Presentation pres = new Presentation("MyPresentation.pptx")) { IAutoShape shape = pres.Slides[0].Shapes[0] as IAutoShape; ITextFrameFormat localTextFrameFormat = shape.TextFrame.TextFrameFormat; ITextFrameFormatEffectiveData effectiveTextFrameFormat = localTextFrameFormat.GetEffective(); IPortionFormat localPortionFormat = shape.TextFrame.Paragraphs[0].Portions[0].PortionFormat; IPortionFormatEffectiveData effectivePortionFormat = localPortionFormat.GetEffective(); }
注意:
GetEffective()方法已添加到ITextFrameFormat、ITextStyle、IParagraphFormat、IPortionFormat、IFillFormat、ILineFormat、IEffectFormat、IThreeDFormat、ITableFormat、IRowFormat、IColumnFormat、ICellFormat、IBackground 和ITheme接口。
這兩個類都是抽象的,并在內部用于維護系統的統一有效值。AccessibleEffectiveData類是具有自己的繼承層次結構的格式的有效數據類的基類。BaseEffectiveData類是AccessibleEffectiveData的基類,也是所有有效數據類的基類,它們沒有自己的繼承層次結構,并且作為更復雜的有效數據類的一部分。
以下是在不同的表示結構級別上設置本地字體高度值后,演示部分的有效字體高度值的代碼。
using (Presentation pres = new Presentation()) { IAutoShape newShape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 400, 75, false); newShape.AddTextFrame(""); newShape.TextFrame.Paragraphs[0].Portions.Clear(); IPortion portion0 = new Portion("Sample text with first portion"); IPortion portion1 = new Portion(" and second portion."); newShape.TextFrame.Paragraphs[0].Portions.Add(portion0); newShape.TextFrame.Paragraphs[0].Portions.Add(portion1); Console.WriteLine("Effective font height just after creation:"); Console.WriteLine("Portion #0: " + portion0.PortionFormat.GetEffective().FontHeight); Console.WriteLine("Portion #1: " + portion1.PortionFormat.GetEffective().FontHeight); pres.DefaultTextStyle.GetLevel(0).DefaultPortionFormat.FontHeight = 24; Console.WriteLine("Effective font height after setting entire presentation default font height:"); Console.WriteLine("Portion #0: " + portion0.PortionFormat.GetEffective().FontHeight); Console.WriteLine("Portion #1: " + portion1.PortionFormat.GetEffective().FontHeight); newShape.TextFrame.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 40; Console.WriteLine("Effective font height after setting paragraph default font height:"); Console.WriteLine("Portion #0: " + portion0.PortionFormat.GetEffective().FontHeight); Console.WriteLine("Portion #1: " + portion1.PortionFormat.GetEffective().FontHeight); newShape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 55; Console.WriteLine("Effective font height after setting portion #0 font height:"); Console.WriteLine("Portion #0: " + portion0.PortionFormat.GetEffective().FontHeight); Console.WriteLine("Portion #1: " + portion1.PortionFormat.GetEffective().FontHeight); newShape.TextFrame.Paragraphs[0].Portions[1].PortionFormat.FontHeight = 18; Console.WriteLine("Effective font height after setting portion #1 font height:"); Console.WriteLine("Portion #0: " + portion0.PortionFormat.GetEffective().FontHeight); Console.WriteLine("Portion #1: " + portion1.PortionFormat.GetEffective().FontHeight); } // Output: // Effective font height just after creation: // Portion #0: 18 // Portion #1: 18 // Effective font height after setting entire presentation default font height: // Portion #0: 24 // Portion #1: 24 // Effective font height after setting paragraph default font height: // Portion #0: 40 // Portion #1: 40 // Effective font height after setting portion #0 font height: // Portion #0: 55 // Portion #1: 40 // Effective font height after setting portion #1 font height: // Portion #0: 55 // Portion #1: 18
*想要購買Aspose正版授權的朋友可以哦~
ASPOSE技術交流QQ群(642018183)已開通,各類資源及時分享,歡迎交流討論!
掃描關注“慧聚IT”微信公眾號,及時獲取更多產品最新動態及最新資訊
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn