Aspose.Words for .Net是一种高级Word文档处理API,用于执行各种文档管理和操作任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Mic/ ] prosoft Word。
令人兴奋的是,在3月开初,.NET版Aspose.Words迎来了2020第+ r Y J a +三次更新!新增了如下四大新功能亮点:
- Xamarin不再需要单独的DLL。
- FindReplaceOptionz 1 x z $ Ps类扩展了新属性。
- 实现了“ Letterlike”符号的正确呈现。
- 支持在文本框范围内动态拉伸图像,从而为LINQ ReporX # b 7 K ] gting Engine保留图像的比例。
>>你可以点击文末“了解更多”下载Aspose.Words for .NET v20.3s D + P g `测试R @ Q | y d体+ % 3 X o验
具体更新内容
key概述类别WORDSNET-18362LINQ Reporting Engine-提供选项以使图像适合文本框范围,同时保持比例新功D 5 = % r S 6能WORDSNET-12 f n H D X F9568提供在IFieldMergingCallback.ImageFieldMerging内设置Shape的不同属性的功能新功能WORDSNET-m Z . v a H *19912FindReplaceOptions的新属性新功能WORDSNET-20012实现侧面的颜色更改新功能WORDSNET-3297考虑添加通过, 7 L - 2 t L书签获取表列o / . ) 2 q 4 0 /的功能新功能WORDSNET-19935为体积形状实现正确的轮廓渲染新功能WORDSNET-19469从DOCX转换为PDF的图表中的轴,数据和图例标签丢失/错误/以不同的颜色显示增强功能WORDSNET-19815请勿将ODT图表转换为形状增强功能WORDSNET-19998为非凸形状` S ! 3 F J 7 m实现正确的轮廓渲染增强功能
公共API更改
添加了一个新的公共属性SaveOptions.UpdateLastPk j A M , p + ( urintedProperty
/// <summary>
/// Gets or sets a va} t k w ] ? 1 / |lue determining whether the BuiltInDocumentPropertT Q {ies.LastPrinted property is updateS ] 7 , v 9 Ad before saving.
/// </su1 } 8 =mmary>
publicboolUpdateLastPrintedProperty
用例
Document doc = new Document(docPath);
SaveOptio] 6 q M 6 ns saveOptions = new PdfSaveOptions();
saveOptions.UpdateLastPrintedProperty = false;
doc.Save(pdfPath, saveOptions);
添加了ImageFieldMergingArgs.Shape属性
客户要求w @ I @ o n在合并图像合并n z ! G O H ) e字段(尤其是WraQ I W 6 /pType)时控制各种图像属性 。当前,只能 分别使用ImageFieldMergingArgs.ImageWidth 和 ImageFieldMergingArgs.ImageHeight属性设置图像的宽度或高度 。Aspose选择了一种更为通- . q F J 1 [ L用的方法,并决定对插入的图像(或任何其他形& * 1 Y状)提供完全控制。 ImageFieldMergingArgs.Shape 属性如下:
/// <summary>
/// Specifies the shape that the! 7 d mail merge engine must insert into the document.
//h ( g/ </summary>
/// <remarks>
/// <p>WhenH . 9 0 j q U j V this property is specified, the mail merge engine ignores all other properties like <see cref=\"ImageFileName\"/> or <see cref=\"ImageStream\"/>
/// and simply inserts the| / T } shape into the document.F O g o y p h R</p>
/// <p>Use this props ; r * l e N i ierty to fully control the process of merginO + 5 * fg an i- _ / p P * v V ;magu F , Be mer| N [ge field.
/// For ex] ; zample, you can specify <see cref=\"ShapeBase.WrapTypea j )\"/> or any other shape property to fi4 I ` S / *ne tune the resulting node. However, please note that
/// you are respong 7 d ~ Esible for providing the contenM ) } ) } % ft of the shape.</p>
/// </remarks>
publicShape Shape {get;set; }] ~ B = T V ) )
如摘要所示,此属性将覆盖其他属性,例如 ImageFileName 或 ImageStream ,即用户只需j + V K指定要u i = K } E插入的形状并设置所有必要的属性即可:
private class TestShapeSeI ` h 3 :tFc F 9 2 ;ield= g Z &MergingCallback : IFieldMergingCallback
{
void IFieldMergingCallback.FieldMerging(F| U k ieldMergingArgsA | t 2 : d args)
{
// ImpleJ G @ ] a #mentation is not r, * h q z V heqk B U } f T |uired.
}
void IFieldMergingCallback., d 8ImageFieldMerging(ImageFieldMergingArgs args)
{K d F { @ t a K
Shape shape = new Shape(args.Document);
shape.Width = 1000;
sh; z Iape.Height = 2000;
shape.WrapType = WrapType.Square;
string imageFileName = \"image.png\";
shape.ImageDZ 0 $ata.SetImage(imageFileName);
args.Shape = shape;
}
}
FindReplaceOptions类扩展了新属性
///
/// Gets or sets a boolean value indicating either to ignore text inside delete revisions.
/// The default valK $ W # 4 v }ue isfalse.
///
publicboolIgnoreDeleted
///
/// Gets or4 T ! sets a boolean value in3 x F q ? ) , edicating either to ignore text inside insert revisions.
/// The default vaA ^ z & # B @ 7lue isfalse.
///
publicboolIa z ? Q ~ ?gnoreIns@ S # 7 A % 0 ,erted
///
///- G R * i 2 C j Gets or sets a boolean valuU 6 7 B E 6 d H ee indicating eithe? s } t Br to ignore text inside fields.
/// ThD = $ : % X ze default value isfalse.
///
publicbooL 0 C U *lIgnoreFields
用例1:说明如何忽略删除修订中的文本
// Create new document.
Document doc = new Document();
DocumentBu% t ^ilder builder = new Document3 I v f w + A l XBuik Z Y l Older(doc);
// Insert nV 7 ] ; C xon-revised text.
builder.Writeln(\"Deleted\");
builder.Write(\"Text\");
// Removeo @ m m first paragraph with tracking revis: q ! S p |ions.
doc.StR u T }artTr: t 0 o w 9 k *ackRevisions(\"author\", DateTime.Now);
doc.FirstSection.Body.FirstParagraph.Remove();3 + K y ] R : Z z
doc.StopU g Y Z e i 0 ` ,Traca g & skRevisions();
Regex regex = new Regex(\"e\");
FindReplaceOptions options = new FindReplaceOptions();
// Replace \'e\l Z r t Y { b | O' in document ignoring deleted te7 D | :xt.
options.IgnoreDeleted = true;
doc.Range.Replace(regex, \"*\", options);
Console.WriteLine(doc.GetTextH K Y P b q()); // The output is: Deleted\\rT*x7 U $ 3 H X 1t\\f
// Replac* N W F e p ` (e \'e\Y o [ 3 @' in document NOT ignoring deleted text.
options.IgnoreDeleted = falseE - *;
doc.Range.Replace(regex, \"*\~ L q I ~ +", options);
Console.WriteLine(doc.GetText())q k . 7 ; U 5; // 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[ h J ~.Now);
builder.Writeln(\"InsertW # ~ 5 X R $ed\");
doc.StopTrackRevisions();
// Insert non-revised text.
builder.Write(\"Text\");
Regex regex = new Regex(\"e\");
FindReplaceOption[ M P . v o U Qs options = new FindReplaceOptions();
// Replace \'e\' in document ignoz ( z )ring inserted text.
options.IgnoreInserted = true;
doc.Range.Replace(regex, \"Y # G 6 H N w N n*5 S L v\", o{ { 1 @ 2ptions);
Console.Wr] D k Y 9 -iteLin/ ? S k de(doc.GetText()); // The outp= O 2 ( z wut is: Insert. 8 I } b ted\\rTQ 9 0 f # #*xt\\f
// Replace \S ; 6 o x x X'e\' in document NOT ignoring inserted text.
options.IgnoreInserted = fa4 y 2 f z } ^lse;
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: \\\\u0013IN# V R - u GCLUDETEXT\\\\u0014Text in field\\\\u0015\\f
// Replace \'e\' in document NOT ignoring text inside field.
options.IgnoreFc & X B A 7ields = false;
doc.RaG & [ n f Inge.Replace(? * l Y qregex, \"*\", options);
Console.WriteLine(doc.GetText()); // The output is: \\\\u0013INCLUDETEXT\\\\u0014T*xt in fi*ld\\d u { ) p 9 h A\u0015\\f
Xamarin不再需要单独* V X & L e ! j的9 x t ~ iDLL
从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 3W K x [ w d.8或更高版本以及Xamarin.Android 8.0或更高版本一起使用。