Aspose.Words for .Net是一種高級Word文檔處理API,用於執行各種文檔管理和操作任務。API支持生成,修改,轉換,呈現和打印文檔,而無需在跨平臺應用程序中直接使用Microsoft Word。2021年6月更新來啦,.NET版Aspose.Words更新至v21.6新版本!
主要特點如下:
- 實現了爲圖表系列、數據點和標記設置填充和描邊格式的功能
- 引入了用於處理紋理的新 API
- 實現了 OOXML Ink(InkML 子集)的渲染
- 引入了 TxtSaveOptions.MaxCharactersPerLine 屬性
- 添加了新的 Document.LayoutOption 以控制連續部分中的頁碼
- 提供了始終爲 LINQ 報告引擎的 JSON 或 XML 根元素生成對象的選項
>>你可以點擊這裏下載Aspose.Words for .NET v21.6測試體驗。
具體更新內容
序號 | 概括 | 類別 |
WORDSNET-21647 | DOCX 轉 PDF:發生內容置換 | 新功能 |
WORDSNET-12748 | 提供API更改圖表類別系列顏色 | 新功能 |
WORDSNET-13907 | 支持渲染 DrawingML InkML ContentPart | 新功能 |
WORDSNET-12275 | 添加功能以更改 ChartSeries 的顏色 | 新功能 |
WORDSNET-21847 | 未應用高級 OpenType 字體功能 | 新功能 |
WORDSNET-21871 | 添加功能以創建帶線條的散點圖 | 新功能 |
WORDSNET-22070 | 提供始終爲 LINQ 報告引擎的 XML 根元素生成對象的選項 | 新功能 |
WORDSNET-12529 | 添加功能以獲取/設置亞洲字符間距屬性 | 新功能 |
WORDSNET-22082 | storeItemChecksum 獲取/設置方法 | 新功能 |
WORDSNET-22002 | 實現 Fill.PresetTextured() 方法 | 新功能 |
WORDSNET-20023 | 允許更改餅圖顏色 | 新功能 |
WORDSNET-21972 | 提供始終爲 LINQ 報告引擎的 JSON 根元素生成對象的選項 | 新功能 |
WORDSNET-15201 | 爲帶有腳註的連續部分實施 MS Word 2013 行爲 | 新功能 |
WORDSNET-17510 | Aspose.Words 不模仿 MS Word 的文檔結構標籤 | 增強 |
WORDSNET-18186 | 從 Word 到 PDF 的轉換過程中丟失了墨跡註釋 | 增強 |
WORDSNET-20020 | 轉換後的 Word 文檔的透明度未顯示在 PDF 中 | 增強 |
WORDSNET-12640 | 添加設置/獲取圖表系列顏色的功能 | 增強 |
WORDSNET-20462 | DOCX轉PDF後手寫內容丟失 | 增強 |
WORDSNET-21156 | LayoutCollector 返回的值不正確 | 增強 |
WORDSNET-19199 | 帶有免費手繪圖像的 DOCX 到 PDF | 增強 |
WORDSNET-22090 | TXT 文件中的每一行都應該有一個固定長度的字符 | 行中允許的最大字符數 | 增強 |
WORDSNET-21795 | DOCX 到 PDF/A 的轉換和驗證失敗:標題內的單詞/空格分隔問題 | 增強 |
完整更新細則請參考:【Aspose.Words for .NET v21.6更新說明】
新功能解析
①在LayoutEnumerator類中爲Kind屬性添加了一個新的LayoutEntityType和新的值
公共枚舉 LayoutEntityType 中添加了一個新值Note:
這將幫助用戶迭代腳註/尾註容器內的註釋。用例如下:
Document doc = new Document("SomeDocument.docx") LayoutEnumerator en = new LayoutEnumerator(doc); // We start from the first page. Debug.Assert(en.Type == LayoutEntityType.Page); // Move to the first column on the page. en.MoveFirstChild(); Debug.Assert(en.Type == LayoutEntityType.Column); // Move to the first child in the column. en.MoveFirstChild(); do { // Iterate to a footnote container. if (en.Type == LayoutEntityType.Footnote) break; } while(en.MoveNext()); // If the footnote container exists in the column, we will process notes. if (en.Type == LayoutEntityType.Footnote) { // Move to the first note in the footnote container. if (en.MoveFirstChild()) { do { // Move over notes inside the footnote container. Debug.Assert(en.Type == LayoutEntityType.Note); // Do something. } while (en.MoveNext()); } } }
LayoutEnumerator 類的新 Kind 枚舉值 LayoutEnumerator 類添加了 8 個新的 Kind 枚舉值:
最有用的值是能夠明確地確定你正在使用的分隔符類型的那種。這是真的,因爲對於所有類型的分隔符,LayoutEntityType是LayoutEntityType.NoteSeparator。用例:
Document doc = new Document("SomeDocument.docx") LayoutEnumerator en = new LayoutEnumerator(doc); // We start from the first page. Debug.Assert(en.Type == LayoutEntityType.Page); // Move to the first column on the page. en.MoveFirstChild(); Debug.Assert(en.Type == LayoutEntityType.Column); // Move to the first child in the column. en.MoveFirstChild(); do { if (en.Type == LayoutEntityType.NoteSeparator && en.Kind == "FOOTNOTESEPARATOR") { // Do something. } if (en.Type == LayoutEntityType.NoteSeparator && en.Kind == "FOOTNOTECONTINUATIONSEPARATOR") { // Do something. } if (en.Type == LayoutEntityType.NoteSeparator && en.Kind == "FOOTNOTECONTINUATIONNOTICE") { // Do something. } } while(en.MoveNext()); }
②添加了新的 Document.LayoutOption 以控制連續部分中的頁碼
添加了一個新的佈局選項來控制 Aspose.Words 在計算重新開始頁碼的連續部分中的頁碼時的行爲:
更改後,默認的 Aspose.Words 行爲與當前的 MS Word 版本 (2019) 匹配。根據 WORDSNET-17760 實現的舊行爲仍然可以通過引入的選項獲得:
Document doc = new Document("input.docx"); doc.LayoutOptions.ContinuousSectionPageNumberingRestart = ContinuosSectionRestart.FromNewPageOnly; doc.Save("out.pdf");
③實現了爲圖表系列、數據點和標記設置填充和描邊格式的能力
新 ChartFormat 類型的屬性已添加到 ChartSeries、ChartDataPoint 和 ChartMarker 類:
此外,一些現有屬性的別名已添加到 Stroke 類:ForeColor、BackColor、Visible 和 Transparency。原始的 Color、Color2、On 和 Opacity 屬性將在 Aspose.Words 的未來版本中過時。
用例:解釋如何設置系列顏色
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Shape shape = builder.InsertChart(ChartType.Column, 432, 252); Chart chart = shape.Chart; ChartSeriesCollection seriesColl = chart.Series; // Delete default generated series. seriesColl.Clear(); // Create category names array. string[] categories = new string[] { "AW Category 1", "AW Category 2" }; // Adding new series. Value and category arrays must be the same size. ChartSeries series1 = seriesColl.Add("AW Series 1", categories, new double[] { 1, 2 }); ChartSeries series2 = seriesColl.Add("AW Series 2", categories, new double[] { 3, 4 }); ChartSeries series3 = seriesColl.Add("AW Series 3", categories, new double[] { 5, 6 }); // Set series color. series1.Format.Fill.ForeColor = Color.Red; series2.Format.Fill.ForeColor = Color.Yellow; series3.Format.Fill.ForeColor = Color.Blue; doc.Save("ColumnColor.docx");
④實現 OOXML Ink(InkML 子集)的渲染
OOXML Ink 內容由 Ink 標記語言的語法和語義子集指定。在此版本之前,Aspose.Words 只能爲 OOXML Ink 對象渲染後備形狀,即實際上並未處理 InkML,而是使用簡單的預渲染圖像。現在可以直接渲染 OOXML 墨跡內容部分(“冷”渲染)。
爲了控制 Ink 渲染的模式,引入了一個新的公共屬性 SaveOptions.ImlRenderingMode 並添加了相應的枚舉:
如果您有任何疑問或需求,請隨時加入Aspose技術交流羣(761297826),我們很高興爲您提供查詢和諮詢。