Aspose.Words for .Net是一种高级Word文档处理API,用于执行各种文档管理和操作任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Microsoft Word。2021年第一版更新来啦,.NET版Aspose.Words更新至v21.1新版本!
主要特点如下:
- 在DocumentBuilder类中引入了StartColumnBookmark和EndColumnBookmark方法。
- 添加MarkdownSaveOptions.ImageSavingCallback以控制在转换为Markdown格式后如何保存图像。
- 添加了在加载HTML时忽略HTML元素的功能。
- TableStyle.VerticalAlignment已公开。
>>你可以点击这里下载Aspose.Words for .NET v21.1测试。
具体更新内容
键
概要
类别
WORDSNET-4987
支持OOXML SmartArt(图表)的“冷”渲染
新功能
WORDSNET-20666
添加功能以创建移动修订
新功能
WORDSNET-21389
将IImageSavingCallback添加到MarkdownSaveOptions中
新功能
WORDSNET-17026
LINQ Reporting Engine-支持部分打破了数据带和条件块的内部
新功能
WORDSNET-20367
向Node类添加字段,以便用户可以在Aspose.Words文档模型中存储一些自定义元数据
新功能
WORDSNET-18882
添加功能以将表的列添加为书签
新功能
WORDSNET-21114
添加功能以使用TableStyle获取或设置单元格垂直对齐方式
新功能
WORDSNET-21426
MS Word应自动选择插入的OLE对象的默认图标
增强功能
WORDSNET-21576
将LastChild属性和AppendChild()方法添加到StructuredDocumentRangeStart类
增强功能
WORDSNET-21433
改进URI处理以处理相对超链接
增强功能
WORDSNET-21493
在父子层次结构中将Word转换为JSON
增强功能
新功能解析
①WORDSNET-21203:添加了新的公共属性Node.CustomNodeId:
客户现在可以跟踪模型树中的节点位置,并根据分配的标识符绑定外部数据,用例如下:
DocumentBuilder builder = new DocumentBuilder();
Shape shape = builder.InsertShape(ShapeType.Rectangle, 100, 100);
shape.CustomNodeId = 100;
②WORDSNET-21114:添加了新的公共属性TableStyle.VerticalAlignment
该选项允许设置表格样式单元格的垂直对齐方式,用例如下:
Document doc = TestUtil.Open(fileName);
TableStyle style = (TableStyle)doc.Styles\["Custom Table 1"\];
style.VerticalAlignment = CellVerticalAlignment.Center;
③WORDSNET-21389:添加MarkdownSaveOptions.ImageSavingCallback
说明将文档保存为Markdown格式时如何使用“ MarkdownSaveOptions.ImageSavingCallback”
public void HandleDocument()
{
const string outFileName = "SavingCallback.DocumentParts.Rendering.md";
// Open a document to be converted to Markdown.
Document doc = new Document("C:\\Rendering.docx");
// We can use an appropriate SaveOptions subclass to customize the conversion process.
MarkdownSaveOptions options = new MarkdownSaveOptions();
// If we convert a document that contains images into Markdown, we will end up with one Markdown file which links to several images.
// Each image will be in the form of a file in the local file system.
// There is also a callback that can customize the name and file system location of each image.
options.ImageSavingCallback = new SavedImageRename(outFileName);
// The ImageSaving() method of our callback will be run at this time.
doc.Save($"C:\\{outFileName}", options);
}
/// <summary>
/// Renames saved images that are produced when an Markdown document is saved.
/// </summary>
public class SavedImageRename : IImageSavingCallback
{
public SavedImageRename(string outFileName)
{
mOutFileName = outFileName;
}
void IImageSavingCallback.ImageSaving(ImageSavingArgs args)
{
string imageFileName = $"{mOutFileName} shape {++mCount}, of type {args.CurrentShape.ShapeType}{Path.GetExtension(args.ImageFileName)}";
args.ImageFileName = imageFileName;
args.ImageStream = new FileStream($"C:\\{imageFileName}", FileMode.Create);
Assert.True(args.ImageStream.CanWrite);
Assert.True(args.IsImageAvailable);
Assert.False(args.KeepImageStreamOpen);
}
private int mCount;
private readonly string mOutFileName;
}
如果您有任何疑问或需求,请随时加入Aspose技术交流群(761297826),我们很高兴为您提供查询和咨询。