原創|產品更新|編輯:李顯亮|2020-03-04 10:59:57.010|閱讀 343 次
概述:令人興奮的是,在3月開初,.NET版Aspose.Words迎來了2020第三次更新!新增了如下四大新功能亮點,本文將為你用示例解析這些新功能。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.Words for .Net是一種高級Word文檔處理API,用于執行各種文檔管理和操作任務。API支持生成,修改,轉換,呈現和打印文檔,而無需在跨平臺應用程序中直接使用Microsoft Word。
令人興奮的是,在3月開初,.NET版Aspose.Words迎來了2020第三次更新!新增了如下四大新功能亮點:
>>你可以點擊這里下載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 | 為非凸形狀實現正確的輪廓渲染 | 增強功能 |
/// <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);
客戶要求在合并圖像合并字段(尤其是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; } }
////// 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
從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或更高版本一起使用。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn