GroupDocs.Conversion for .NET v26.6 現已推出。此版本加入了更豐富的轉換事件支援、PDF 轉 Markdown 的自訂影像處理、DOCX 的 RTL 自動偵測,以及多項穩定性改進。

本次發行的新功能

Key Category Summary
CONVERSIONNET-7934 Feature PDF to Markdown:允許自訂影像抽取與佔位符插入
CONVERSIONNET-8286 Feature 引入 ConversionEvents 聚合器,支援每次呼叫/全域處理程式的優先順序
CONVERSIONNET-8314 Feature 新增 OnFontSubstituted 轉換事件
CONVERSIONNET-8263 Improvement NuGet 套件拆分
CONVERSIONNET-8280 Improvement 自動偵測缺少/錯誤雙向文字標記的 DOCX 之 RTL 方向
CONVERSIONNET-8325 Improvement 當工作表含有表單控制項時,Spreadsheet 轉 PDF 時的 SkipEmptyRowsAndColumns 會與文字重疊
CONVERSIONNET-7912 Bug JPEG/TIFF 輸出中出現損壞字元
CONVERSIONNET-8281 Bug 轉換特定 XFA PDF 為影像時卡住且不產生任何結果
CONVERSIONNET-8321 Bug 轉換 Publisher 時的問題 – 無法載入 Aspose.PDF

公開 API 變更

⚠️ Breaking changes

  • 事件名稱已重新命名,且事件聚合模型已變更。現有的每結果事件屬性與流暢鏈式方法已 過時,將於 v26.9 中移除。
  • ConverterSettings.ListenerIConverterListener 介面已 過時;它們已被 ConversionEvents 上的生命週期事件取代。
  • 舊的 OnConversionCompleted 每文件事件已重新命名為 OnDocumentConverted。相同名稱現在用於在轉換執行結束時觸發一次的管線生命週期事件。

1. 新的字型替換事件

API Description
ConversionEvents.OnFontSubstituted 當來源文件所需的字型缺失且使用了替代字型(自動或透過使用者自訂規則)時觸發。
FontSubstitutionContext 提供替換的詳細資訊:SourceFileNameOriginalFontNameSubstituteFontNameReason
FontSubstitute 代表使用者提供的替換規則(例如 FontSubstitute.Create("MissingFont", "Arial"))。

Reference:

Classic API example

using GroupDocs.Conversion;
using GroupDocs.Conversion.Contracts;
using GroupDocs.Conversion.Options.Convert;

var events = new ConversionEvents
{
    OnFontSubstituted = ctx =>
    {
        var detail = ctx.OriginalFontName != null
            ? $"{ctx.OriginalFontName} -> {ctx.SubstituteFontName}"
            : ctx.Reason;
        Console.WriteLine($"Font substituted in '{ctx.SourceFileName}': {detail}");
    }
};

using var converter = new Converter(
    "source.docx",
    () => new ConverterSettings(),
    () => events);

converter.Convert("output.pdf", new PdfConvertOptions());

Fluent API example

FluentConverter
    .WithEvents(e => e.OnFontSubstituted = ctx =>
        Console.WriteLine($"Font substituted: {ctx.Reason ?? ctx.OriginalFontName}"))
    .Load("source.docx")
    .ConvertTo("output.pdf")
    .WithOptions(new PdfConvertOptions())
    .Convert();

Substitution rule example (Word‑processing / Spreadsheet / PDF)

using GroupDocs.Conversion.Options.Load;

using var converter = new Converter(
    "source.docx",
    _ => new WordProcessingLoadOptions
    {
        FontSubstitutes = new List<FontSubstitute>
        {
            FontSubstitute.Create("MissingFont", "Arial")
        }
    },
    () => new ConverterSettings(),
    () => events);

converter.Convert("output.pdf", new PdfConvertOptions());

2. Unified event