GroupDocs.Conversion For .NET 3.1.0 Release Notes

Major Features

There are 4 new features in this regular monthly release. The most notable are:

  • Detecting document type from streams.
  • Document conversion progress.

All Changes

KeySummaryCategory
CONVERSIONNET-680Implement document conversion from stream with auto detect source file typeNew Feature
CONVERSIONNET-662Autodetect source document type when converting from streamNew Feature
CONVERSIONNET-655Report conversion progressNew Feature
CONVERSIONNET-654Return all supported conversions types with single methodNew Feature

Public API and Backward Incompatible Changes

How to get available save options for a document by file extension

const string sourceDocument = "source.docx";
// Setup Conversion configuration
var conversionConfig = new ConversionConfig();
var conversionHandler = new ConversionHandler(conversionConfig);
var documentExtension = Path.GetExtension(sourceDocument).TrimStart('.');
//returns IDictionary<string, SaveOptions>
var availableConversions = conversionHandler.GetSaveOptions(documentExtension);
//list all available conversions
foreach (var name in availableConversions.Keys)
{
Console.WriteLine(name);
}
//use prepared save option for ToPdf conversion
var result = conversionHandler.Convert<string>("test.doc", availableConversions["pdf"]);
 

How to get available save options for a document stream

const string sourceDocument = "source.docx";
// Setup Conversion configuration
var conversionConfig = new ConversionConfig();
var conversionHandler = new ConversionHandler(conversionConfig);
var sourceStream = new FileStream(sourceDocument, FileMode.Open);
//returns IDictionary<string, SaveOptions>
var availableConversions = conversionHandler.GetSaveOptions(sourceStream);
//list all available conversions
foreach (var name in availableConversions.Keys)
{
Console.WriteLine(name);
}
//use prepared save option for ToPdf conversion
var result = conversionHandler.Convert<string>(sourceStream, availableConversions["pdf"]);
 

How to get conversion progress

const string sourceFileName = "sample.doc"; //TODO: Put the source filename here
// Setup Conversion configuration
var conversionConfig = new ConversionConfig
{
CachePath = "cache",
StoragePath = "."
};
var conversionHandler = new ConversionHandler(conversionConfig);
conversionHandler.ConversionProgress += ConversionProgressHandler;
var resultPath = conversionHandler.Convert<string>(sourceFileName,
new PdfSaveOptions { OutputType = OutputType.String });
Console.WriteLine("The conversion finished. The result can be located here: {0}. Press <<ENTER>> to exit.",
resultPath);
Console.ReadLine();
 

Conversion progress handler

private static void ConversionProgressHandler(object sender,
ConversionProgressEventArgs args)
{
Console.WriteLine("Conversion progress: {0}", args.Progress);
}