.NET版Word格式处理控件Aspose.Words v20.3新版上线!解析9大增强新功能!

令人兴奋的是,在3月开初,.NET版Aspose.Words迎来了2020第三次更新!新增了如下四大新功能亮点,本文将为你用示例解析这些新功能。

Aspose.Words for .Net是一种高级Word文档处理API,用于执行各种文档管理和操作任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Microsoft Word。

令人兴奋的是,在3月开初,.NET版Aspose.Words迎来了2020第三次更新!新增了如下四大新功能亮点:

  • Xamarin不再需要单独的DLL。
  • FindReplaceOptions类扩展了新属性。
  • 实现了“ Letterlike”符号的正确呈现。
  • 支持在文本框范围内动态拉伸图像,从而为LINQ Reporting Engine保留图像的比例。

>>你可以点击这里下载Aspose.Words for .NET v20.3测试体验

具体更新内容

key 概述 类别
WORDSNET-18362 LINQ Reporting Engine-提供选项以使图像适合文本框范围,同时保持比例 新功能
WORDSNET-19568 提供在IFieldMergingCallback.ImageFieldMerging内设置Shape的不同属性的功能 新功能
WORDSNET-19912 FindReplaceOptions的新属性 新功能
WORDSNET-20012 实现侧面的颜色更改 新功能
WORDSNET-3297 考虑添加通过书签获取表列的功能 新功能
WORDSNET-19935 为体积形状实现正确的轮廓渲染 新功能
WORDSNET-19469 从DOCX转换为PDF的图表中的轴,数据和图例标签丢失/错误/以不同的颜色显示 增强功能
WORDSNET-19815 请勿将ODT图表转换为形状 增强功能
WORDSNET-19998 为非凸形状实现正确的轮廓渲染 增强功能

完整更新细则请参考:【Aspose.Words for .NET v20.3更新说明】

公共API更改

添加了一个新的公共属性SaveOptions.UpdateLastPrintedProperty

/// <summary>/// Gets or sets a value determining whether the BuiltInDocumentProperties.LastPrinted property is updated before saving./// </summary>publicboolUpdateLastPrintedProperty

用例

Document doc = new Document(docPath);SaveOptions saveOptions = new PdfSaveOptions();saveOptions.UpdateLastPrintedProperty = false;doc.Save(pdfPath, saveOptions);

添加了ImageFieldMergingArgs.Shape属性

客户要求在合并图像合并字段(尤其是WrapType)时控制各种图像属性 。当前,只能 分别使用ImageFieldMergingArgs.ImageWidth 和 ImageFieldMergingArgs.ImageHeight属性设置图像的宽度或高度 。Aspose选择了一种更为通用的方法,并决定对插入的图像(或任何其他形状)提供完全控制。 ImageFieldMergingArgs.Shape 属性如下:

/// <summary>/// Specifies the shape that the mail merge engine must insert into the document./// </summary>/// <remarks>/// <p>When this property is specified, the mail merge engine ignores all other properties like <see cref="ImageFileName"/> or <see cref="ImageStream"/>/// and simply inserts the shape into the document.</p>/// <p>Use this property to fully control the process of merging an image merge field./// For example, you can specify <see cref="ShapeBase.WrapType"/> or any other shape property to fine tune the resulting node. However, please note that/// you are responsible for providing the content of the shape.</p>/// </remarks>publicShape Shape {get;set; }

如摘要所示,此属性将覆盖其他属性,例如 ImageFileName 或 ImageStream ,即用户只需指定要插入的形状并设置所有必要的属性即可:

private class TestShapeSetFieldMergingCallback : IFieldMergingCallback{    void IFieldMergingCallback.FieldMerging(FieldMergingArgs args)    {        //  Implementation is not required.    }     void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs args)    {        Shape shape = new Shape(args.Document);        shape.Width = 1000;        shape.Height = 2000;        shape.WrapType = WrapType.Square;         string imageFileName = "image.png";        shape.ImageData.SetImage(imageFileName);         args.Shape = shape;    }}

FindReplaceOptions类扩展了新属性

////// Gets or sets a boolean value indicating either to ignore text inside delete revisions./// The default value isfalse.///publicboolIgnoreDeleted
////// Gets or sets a boolean value indicating either to ignore text inside insert revisions./// The default value isfalse.///publicboolIgnoreInserted
////// Gets or sets a boolean value indicating either to ignore text inside fields./// The default value isfalse.///publicboolIgnoreFields

用例1:说明如何忽略删除修订中的文本

// Create new document.Document doc = new Document();DocumentBuilder builder = new DocumentBuilder(doc); // Insert non-revised text.builder.Writeln("Deleted");builder.Write("Text"); // Remove first paragraph with tracking revisions.doc.StartTrackRevisions("author", DateTime.Now);doc.FirstSection.Body.FirstParagraph.Remove();doc.StopTrackRevisions(); Regex regex = new Regex("e");FindReplaceOptions options = new FindReplaceOptions(); // Replace 'e' in document ignoring deleted text.options.IgnoreDeleted = true;doc.Range.Replace(regex, "*", options);Console.WriteLine(doc.GetText()); // The output is: DeletedrT*xtf // Replace 'e' in document NOT ignoring deleted text.options.IgnoreDeleted = false;doc.Range.Replace(regex, "*", options);Console.WriteLine(doc.GetText()); // The output is: D*l*t*drT*xtf

用例2:说明如何忽略插入修订中的文本

// Create new document.Document doc = new Document();DocumentBuilder builder = new DocumentBuilder(doc); // Insert text with tracking revisions.doc.StartTrackRevisions("author", DateTime.Now);builder.Writeln("Inserted");doc.StopTrackRevisions(); // Insert non-revised text.builder.Write("Text"); Regex regex = new Regex("e");FindReplaceOptions options = new FindReplaceOptions(); // Replace 'e' in document ignoring inserted text.options.IgnoreInserted = true;doc.Range.Replace(regex, "*", options);Console.WriteLine(doc.GetText()); // The output is: InsertedrT*xtf // Replace 'e' in document NOT ignoring inserted text.options.IgnoreInserted = false;doc.Range.Replace(regex, "*", options);Console.WriteLine(doc.GetText()); // The output is: Ins*rt*drT*xtf

用例3:说明如何忽略字段内的文本

// Create document.Document doc = new Document();DocumentBuilder builder = new DocumentBuilder(doc); // Insert field with text inside.builder.InsertField("INCLUDETEXT", "Text in field"); Regex regex = new Regex("e");FindReplaceOptions options = new FindReplaceOptions(); // Replace 'e' in document ignoring text inside field.options.IgnoreFields = true;doc.Range.Replace(regex, "*", options);Console.WriteLine(doc.GetText()); // The output is: u0013INCLUDETEXTu0014Text in fieldu0015f // Replace 'e' in document NOT ignoring text inside field.options.IgnoreFields = false;doc.Range.Replace(regex, "*", options);Console.WriteLine(doc.GetText()); // The output is: u0013INCLUDETEXTu0014T*xt in fi*ldu0015f

Xamarin不再需要单独的DLL

从Aspose.Words 20.3开始,Xamarin支持已更改。在早期版本中,我们为Xamarin.Android,Xamarin.Mac和Xamarin.iOS提供了单独的DLL。现在Xamarin开发人员可以在所有提到的平台中使用Aspose.Words for .NET Standard。根据.NET Standard文档,用于.NET Standard 2.0的Aspose.Words可以与Xamarin.iOS 10.14或更高版本,Xamarin.Mac 3.8或更高版本以及Xamarin.Android 8.0或更高版本一起使用。


还想要更多吗可以点击阅读【2019 · Aspose最新资源整合】查找需要的教程资源。如果您有任何疑问或需求,请随时联系客服,我们很高兴为您提供查询和咨询
标签:

来源:慧都

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年1月2日
下一篇 2020年1月2日

相关推荐

发表回复

登录后才能评论