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:

aspose word好用吗(aspose word 教程)(1)

这将帮助用户迭代脚注/尾注容器内的注释。用例如下:

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

aspose word好用吗(aspose word 教程)(2)

最有用的值是能够明确地确定你正在使用的分隔符类型的那种。这是真的,因为对于所有类型的分隔符,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 word好用吗(aspose word 教程)(3)

更改后,默认的 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 类:

aspose word好用吗(aspose word 教程)(4)

此外,一些现有属性的别名已添加到 Stroke 类:ForeColor、BackColor、Visible 和 Transparency。原始的 Color、Color2、On 和 Opacity 属性将在 Aspose.Words 的未来版本中过时。

aspose word好用吗(aspose word 教程)(5)

用例:解释如何设置系列颜色

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 word好用吗(aspose word 教程)(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:

aspose word好用吗(aspose word 教程)(7)

这将帮助用户迭代脚注/尾注容器内的注释。用例如下:

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

aspose word好用吗(aspose word 教程)(8)

最有用的值是能够明确地确定你正在使用的分隔符类型的那种。这是真的,因为对于所有类型的分隔符,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 word好用吗(aspose word 教程)(9)

更改后,默认的 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 类:

aspose word好用吗(aspose word 教程)(10)

此外,一些现有属性的别名已添加到 Stroke 类:ForeColor、BackColor、Visible 和 Transparency。原始的 Color、Color2、On 和 Opacity 属性将在 Aspose.Words 的未来版本中过时。

aspose word好用吗(aspose word 教程)(11)

用例:解释如何设置系列颜色

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 word好用吗(aspose word 教程)(12)

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页