GroupDocs.Conversion for .NET 18.6 Release Notes

Major Features

This regular monthly release contains simplified instantiation of the conversion handler and abstraction for handling streams for temp operation. 

  • Reducing ConversionHandler constructors to one
  • Introduced ITempDataHandler for handling temp operations stream
  • Introducing new properties in ConversionConfig for different handler types

Full List of Issues Covering all Changes in this Release

KeySummaryCategory
CONVERSIONNET-2597Reducing ConversionHandler constructors to oneImprovement
CONVERSIONNET-2598Introduced ITempDataHandler for handling temp operations streamImprovement
CONVERSIONNET-2599Introducing new properties in ConversionConfig for different handler typesImprovement

Public API and Backward Incompatible Changes

v18.6 New ITempDataHandler abstraction for providing custom implementation for providing temp stream

New ITempDataHandler

/// <summary>
/// Implement this interface to provide custom way of handling temporary files
/// </summary>
public interface ITempDataHandler
{
     /// <summary>
     /// Gets stream for temporary file. This stream usually should be only for writing.
     /// </summary>
     /// <returns></returns>
     Stream CreateTempStream();
}

Usage

// custom implementation of ITempDataHandler
internal class MyTempDataHandler : ITempDataHandler
{
     public Stream CreateTempStream()
     {
         return new FileStream(string.Format(@"c:\temp\gd-{0:N}.tmp", Guid.NewGuid()), FileMode.Create);
     }
}
 
...
 
// provide instance of the above implementation to the Conversion handler
var config = new ConversionConfig
            {
                TempDataHandler = new MyTempDataHandler(),
                StoragePath = ".", 
                OutputPath = "."
            };
             
var handler = new ConversionHandler(config);
const string sourceFile = @"source.docx";
var result = handler.Convert(sourceFile, new PdfSaveOptions());
result.Save("converted.pdf");
 
Console.WriteLine("Done!");
Console.ReadKey();

v18.6 New properties in ConversionConfig for providing custom DataHandlers instances

New properties in ConversionConfig

All constructors listed below are obsolete

/// <summary>
/// Custom implementation of <see cref="IInputDataHandler" /> interface
/// </summary>
public IInputDataHandler InputDataHandler { get; set; }
 
 
/// <summary>
/// Custom implementation of <see cref="IOutputDataHandler" /> interface
/// </summary>
public IOutputDataHandler OutputDataHandler { get; set; }
 
 
/// <summary>
/// Custom implementation of <see cref="ICacheDataHandler" /> interface
/// </summary>
public ICacheDataHandler CacheDataHandler { get; set; }
 
/// <summary>
/// Custom implementation of <see cref="ITempDataHandler" /> interface
/// </summary>
public ITempDataHandler TempDataHandler { get; set; }

Usage

var config = new ConversionConfig
            {
                TempDataHandler = new MyTempDataHandler(),
                StoragePath = ".", 
                OutputPath = "."
            };
             
var handler = new ConversionHandler(config);

v18.6 Obsolete ConversionHandler constructors 

All constructors listed below are obsolete

public ConversionHandler(ConversionConfig conversionConfig, IInputDataHandler inputDataHandler);
public ConversionHandler(ConversionConfig conversionConfig, ICacheDataHandler cacheDataHandler);
public ConversionHandler(ConversionConfig conversionConfig, IOutputDataHandler outputDataHandler);
public ConversionHandler(ConversionConfig conversionConfig, IInputDataHandler inputDataHandler, IOutputDataHandler outputDataHandler);
public ConversionHandler(ConversionConfig conversionConfig, IInputDataHandler inputDataHandler, ICacheDataHandler cacheDataHandler);
public ConversionHandler(ConversionConfig conversionConfig, IOutputDataHandler outputDataHandler, ICacheDataHandler cacheDataHandler);
public ConversionHandler(ConversionConfig conversionConfig, IInputDataHandler inputDataHandler, IOutputDataHandler outputDataHandler, ICacheDataHandler cacheDataHandler);

There is only one constructor left:

public ConversionHandler(ConversionConfig conversionConfig)

Usage

var config = new ConversionConfig
            {
                TempDataHandler = new MyTempDataHandler(),
                StoragePath = ".", 
                OutputPath = "."
            };
             
var handler = new ConversionHandler(config);