03.05 解析9大新功能!.NET版Word處理控件Aspose.Words v20.3上線

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測試體驗


解析9大新功能!.NET版Word處理控件Aspose.Words 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.

///

publicboolUpdateLastPrintedProperty

用例

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

添加了ImageFieldMergingArgs.Shape屬性

客戶要求在合併圖像合併字段(尤其是WrapType)時控制各種圖像屬性 。當前,只能 分別使用ImageFieldMergingArgs.ImageWidth 和 ImageFieldMergingArgs.ImageHeight屬性設置圖像的寬度或高度 。Aspose選擇了一種更為通用的方法,並決定對插入的圖像(或任何其他形狀)提供完全控制。 ImageFieldMergingArgs.Shape 屬性如下:

/// <summary>

/// Specifies the shape that the mail merge engine must insert into the document.

///

/// <remarks>

///

When this property is specified, the mail merge engine ignores all other properties like or

/// and simply inserts the shape into the document.

///

Use this property to fully control the process of merging an image merge field.

/// For example, you can specify 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.

///

publicShape Shape {get;set; }

如摘要所示,此屬性將覆蓋其他屬性,例如 ImageFileName 或 ImageStream ,即用戶只需指定要插入的形狀並設置所有必要的屬性即可:

<code>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;
}
}/<code>

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:說明如何忽略刪除修訂中的文本

<code>// 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/<code>

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

<code>// 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/<code>

用例3:說明如何忽略字段內的文本

<code>// 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/<code>

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或更高版本一起使用。


分享到:


相關文章: