aspose word 教程:aspose word好用嗎

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 根元素生成對象的選項

具體更新內容

序號概括類別
WORDSNET-21647DOCX 轉 PDF:發生內容置換新功能
WORDSNET-12748提供API更改圖表類別系列顏色新功能
WORDSNET-13907支持渲染 DrawingML InkML ContentPart新功能
WORDSNET-12275添加功能以更改 ChartSeries 的顏色新功能
WORDSNET-21847未應用高級 OpenType 字體功能新功能
WORDSNET-21871添加功能以創建帶線條的散點圖新功能
WORDSNET-22070提供始終為 LINQ 報告引擎的 XML 根元素生成對象的選項新功能
WORDSNET-12529添加功能以獲取/設置亞洲字符間距屬性新功能
WORDSNET-22082storeItemChecksum 獲取/設置方法新功能
WORDSNET-22002實現 Fill.PresetTextured() 方法新功能
WORDSNET-20023允許更改餅圖顏色新功能
WORDSNET-21972提供始終為 LINQ 報告引擎的 JSON 根元素生成對象的選項新功能
WORDSNET-15201為帶有腳註的連續部分實施 MS Word 2013 行為新功能
WORDSNET-17510Aspose.Words 不模仿 MS Word 的文檔結構標籤增強
WORDSNET-18186從 Word 到 PDF 的轉換過程中丟失了墨跡注釋增強
WORDSNET-20020轉換後的 Word 文檔的透明度未顯示在 PDF 中增強
WORDSNET-12640添加設置/獲取圖表系列顏色的功能增強
WORDSNET-20462DOCX轉PDF後手寫內容丟失增強
WORDSNET-21156LayoutCollector 返回的值不正確增強
WORDSNET-19199帶有免費手繪圖像的 DOCX 到 PDF增強
WORDSNET-22090TXT 文件中的每一行都應該有一個固定長度的字符 | 行中允許的最大字符數增強
WORDSNET-21795DOCX 到 PDF/A 的轉換和驗證失敗:標題內的單詞/空格分隔問題增強

新功能解析

①在LayoutEnumerator類中為Kind屬性添加了一個新的LayoutEntityType和新的值

公共枚舉 LayoutEntityType 中添加了一個新值Note:

5分鐘帶你快速瀏覽Aspose.Words文檔開發工具6月最新版本

這將幫助用戶迭代腳註/尾注容器內的注釋。用例如下:

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 枚舉值:

5分鐘帶你快速瀏覽Aspose.Words文檔開發工具6月最新版本

最有用的值是能夠明確地確定你正在使用的分隔符類型的那種。這是真的,因為對於所有類型的分隔符,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 在計算重新開始頁碼的連續部分中的頁碼時的行為:

5分鐘帶你快速瀏覽Aspose.Words文檔開發工具6月最新版本

更改後,默認的 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 類:

5分鐘帶你快速瀏覽Aspose.Words文檔開發工具6月最新版本

此外,一些現有屬性的別名已添加到 Stroke 類:ForeColor、BackColor、Visible 和 Transparency。原始的 Color、Color2、On 和 Opacity 屬性將在 Aspose.Words 的未來版本中過時。

5分鐘帶你快速瀏覽Aspose.Words文檔開發工具6月最新版本

用例:解釋如何設置系列顏色

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 並添加了相應的枚舉:

5分鐘帶你快速瀏覽Aspose.Words文檔開發工具6月最新版本

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-21647DOCX 轉 PDF:發生內容置換新功能
WORDSNET-12748提供API更改圖表類別系列顏色新功能
WORDSNET-13907支持渲染 DrawingML InkML ContentPart新功能
WORDSNET-12275添加功能以更改 ChartSeries 的顏色新功能
WORDSNET-21847未應用高級 OpenType 字體功能新功能
WORDSNET-21871添加功能以創建帶線條的散點圖新功能
WORDSNET-22070提供始終為 LINQ 報告引擎的 XML 根元素生成對象的選項新功能
WORDSNET-12529添加功能以獲取/設置亞洲字符間距屬性新功能
WORDSNET-22082storeItemChecksum 獲取/設置方法新功能
WORDSNET-22002實現 Fill.PresetTextured() 方法新功能
WORDSNET-20023允許更改餅圖顏色新功能
WORDSNET-21972提供始終為 LINQ 報告引擎的 JSON 根元素生成對象的選項新功能
WORDSNET-15201為帶有腳註的連續部分實施 MS Word 2013 行為新功能
WORDSNET-17510Aspose.Words 不模仿 MS Word 的文檔結構標籤增強
WORDSNET-18186從 Word 到 PDF 的轉換過程中丟失了墨跡注釋增強
WORDSNET-20020轉換後的 Word 文檔的透明度未顯示在 PDF 中增強
WORDSNET-12640添加設置/獲取圖表系列顏色的功能增強
WORDSNET-20462DOCX轉PDF後手寫內容丟失增強
WORDSNET-21156LayoutCollector 返回的值不正確增強
WORDSNET-19199帶有免費手繪圖像的 DOCX 到 PDF增強
WORDSNET-22090TXT 文件中的每一行都應該有一個固定長度的字符 | 行中允許的最大字符數增強
WORDSNET-21795DOCX 到 PDF/A 的轉換和驗證失敗:標題內的單詞/空格分隔問題增強

新功能解析

①在LayoutEnumerator類中為Kind屬性添加了一個新的LayoutEntityType和新的值

公共枚舉 LayoutEntityType 中添加了一個新值Note:

5分鐘帶你快速瀏覽Aspose.Words文檔開發工具6月最新版本

這將幫助用戶迭代腳註/尾注容器內的注釋。用例如下:

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 枚舉值:

5分鐘帶你快速瀏覽Aspose.Words文檔開發工具6月最新版本

最有用的值是能夠明確地確定你正在使用的分隔符類型的那種。這是真的,因為對於所有類型的分隔符,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 在計算重新開始頁碼的連續部分中的頁碼時的行為:

5分鐘帶你快速瀏覽Aspose.Words文檔開發工具6月最新版本

更改後,默認的 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 類:

5分鐘帶你快速瀏覽Aspose.Words文檔開發工具6月最新版本

此外,一些現有屬性的別名已添加到 Stroke 類:ForeColor、BackColor、Visible 和 Transparency。原始的 Color、Color2、On 和 Opacity 屬性將在 Aspose.Words 的未來版本中過時。

5分鐘帶你快速瀏覽Aspose.Words文檔開發工具6月最新版本

用例:解釋如何設置系列顏色

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 並添加了相應的枚舉:

5分鐘帶你快速瀏覽Aspose.Words文檔開發工具6月最新版本

原創文章,作者:投稿專員,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/226453.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
投稿專員的頭像投稿專員
上一篇 2024-12-09 14:50
下一篇 2024-12-09 14:50

相關推薦

發表回復

登錄後才能評論