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

Aspose.Words for .NET 20.3版本发布,带来了新功能,包括Xamarin不再需要单独的DLL,FindReplaceOptions类的扩展,ImageFieldMergingArgs增加Shape属性,以及对Letterlike符号的正确呈现。这些更新将提升文档管理和处理的效率和灵活性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

用例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: Inserted\rT*xt\f
  
// 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*d\rT*xt\f

用例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: \u0013INCLUDETEXT\u0014Text in field\u0015\f
  
// Replace 'e' in document NOT ignoring text inside field.
options.IgnoreFields = false;
doc.Range.Replace(regex, "*", options);
Console.WriteLine(doc.GetText()); // The output is: \u0013INCLUDETEXT\u0014T*xt in fi*ld\u0015\f
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或更高版本一起使用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值