原創(chuàng)|行業(yè)資訊|編輯:李顯亮|2019-09-02 14:43:36.397|閱讀 220 次
概述:Aspose.Slides for .NET是獨(dú)特的演示處理API,使應(yīng)用程序能夠讀取,編寫,修改和轉(zhuǎn)換PowerPoint演示文稿。Aspose.Slides for .NET更新至最新版v19.8,引入了用于獲得有效值的新API,從而獲取“本地”值和“有效”值。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.Slides for .NET是獨(dú)特的演示處理API,使應(yīng)用程序能夠讀取,編寫,修改和轉(zhuǎn)換PowerPoint演示文稿。作為獨(dú)立的API,它提供了管理PowerPoint關(guān)鍵功能的功能,例如管理文本,形狀,表格和動(dòng)畫,向幻燈片添加音頻和視頻,預(yù)覽幻燈片等等。
Aspose.Slides for .NET更新至最新版v19.8,引入了用于獲得有效值的新API,從而獲取“本地”值和“有效”值。下面我們一起來了解一下具體內(nèi)容吧!>>歡迎下載Aspose.Slides for .NET v19.8體驗(yàn)
新的功能支持通過IPortion.PortionFormat在不同級(jí)別的表示結(jié)構(gòu)層次結(jié)構(gòu)中設(shè)置文本部分的屬性。以下是其中一些:
對于任何這些級(jí)別,直接在此級(jí)別設(shè)置的值稱為“本地”。在任何級(jí)別,可以定義或省略“本地”值。但最后,當(dāng)應(yīng)用程序(使用Aspose.Slides甚至PowerPoint本身構(gòu)建)需要知道該部分應(yīng)該是什么樣的時(shí)候(在圖像導(dǎo)出或在屏幕上繪圖時(shí)),它使用“有效”值 - 完全使用層次結(jié)構(gòu)構(gòu)建的已定義值集,可能的值覆蓋最低層的每個(gè)級(jí)別以及硬編碼到PowerPoint中的默認(rèn)值。
“有效數(shù)據(jù)”對象本質(zhì)上是不可變的-它們僅用于獲取最終的組合信息。“本地?cái)?shù)據(jù)“”對象是可變的-它們用于設(shè)置屬性。
啟動(dòng)Aspose.Slides v19.8所需要的只是從您希望獲得有效值的本地格式調(diào)用GetEffective()方法。下面列舉個(gè)例子說明:
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接口。
這兩個(gè)類都是抽象的,并在內(nèi)部用于維護(hù)系統(tǒng)的統(tǒng)一有效值。AccessibleEffectiveData類是具有自己的繼承層次結(jié)構(gòu)的格式的有效數(shù)據(jù)類的基類。BaseEffectiveData類是AccessibleEffectiveData的基類,也是所有有效數(shù)據(jù)類的基類,它們沒有自己的繼承層次結(jié)構(gòu),并且作為更復(fù)雜的有效數(shù)據(jù)類的一部分。
以下是在不同的表示結(jié)構(gòu)級(jí)別上設(shè)置本地字體高度值后,演示部分的有效字體高度值的代碼。
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正版授權(quán)的朋友可以哦~
ASPOSE技術(shù)交流QQ群(642018183)已開通,各類資源及時(shí)分享,歡迎交流討論!
掃描關(guān)注“慧聚IT”微信公眾號(hào),及時(shí)獲取更多產(chǎn)品最新動(dòng)態(tài)及最新資訊
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn