Word文檔管理工具Aspose.Words 2021第一版發佈!支持創建移動修訂

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),我們很高興爲您提供查詢和諮詢

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章