GroupDocs.Conversion For .NET 3.2.0 Release Notes

Major Features

These are improvements and fixes in this regular monthly release. The most notable are:

  • When converting to PDF return each page in separate stream
  • When converting to HTML return each page in separate stream
  • Place watermark in the converted document
  • Add support for converting to PSD format
  • Add support for converting from PSD format
  • Introducing two public interfaces IConversionProgressListener and IConversionStatusListener
  • Implement ConversionCompleted event with conversion details
  • Show grid lines when converting Excel files
  • Show hidden sheets when converting Excel files
  • Return conversion guid in ConversionProgressEventArgs

All Changes

KeySummaryCategory
CONVERSIONNET-684When converting to PDF return each page in separate streamNew Feature
CONVERSIONNET-685When converting to HTML return each page in separate streamNew Feature
CONVERSIONNET-723Place watermark in the converted documentNew Feature
CONVERSIONNET-724Add support for converting to PSD formatNew Feature
CONVERSIONNET-725Add support for converting from PSD formatNew Feature
CONVERSIONNET-789Implement ConversionCompleted event with conversion detailsNew Feature
CONVERSIONNET-807ConversionStart eventNew Feature
CONVERSIONNET-812Introducing two public interfaces IConversionProgressListener and IConversionStatusListenerNew Feature
CONVERSIONNET-816Show grid lines when converting Excel filesNew Feature
CONVERSIONNET-817Show hidden sheets when converting Excel filesNew Feature
CONVERSIONNET-765Return conversion guid in ConversionProgressEventArgsImprovement
CONVERSIONNET-710Client Response - In-Proper conversion From PPTX to PDF, Image and Word Document formatsBug
CONVERSIONNET-722Exception when converting from ODP to PPT and PPSBug
CONVERSIONNET-734While Converting Xlsx file to HTML with HtmlSaveOptions Specific Pages (Sheets) does not workBug
CONVERSIONNET-740Client Response - HTML to Doc and Docx is not proper for Headings and contents are mixedBug
CONVERSIONNET-749Client Response - Only first page converts to PNG from TIF file (With and Without License)Bug
CONVERSIONNET-750Client Response - Convert to HTML from Excel, PDF, MS Word overlaps the images AND some of Words with stylingBug
CONVERSIONNET-757Can not find CallBack function to get Conversion Progress for MVC/WebForms ApplicationsBug
CONVERSIONNET-767Client Respose - Could not open the file stream on azure.Bug
CONVERSIONNET-782Client Response - FileType not supported Exceptions are not handledBug
CONVERSIONNET-783Client Response - Error for Empty Input Documents as Stream for ConversionBug

Public API and Backward Incompatible Changes

How to use PageMode when converting to Html or Pdf

When converting to Html or Pdf developers may get conversion result as separate stream or file path for each page from source document.

Usage of PageMode when converting to PDF

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);
var saveOptions = new PdfSaveOptions {
    OutputType = OutputType.String,
    PageMode = true
};

//Note: when using PageMode expected result is either IList<string> or IList<Stream> depending
// of used OutputType in save options provided
var resultPaths = conversionHandler.Convert<IList<string>>(sourceFileName, saveOptions);

foreach(var path in resultPaths) {
  Console.WriteLine("{0}", path);
}
Console.ReadLine();
 

Usage of PageMode when converting to HTML

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);
var saveOptions = new HtmlSaveOptions {
    OutputType = OutputType.String,

    PageMode = true
};


//Note: when using PageMode expected result is either IList<string> or IList<Stream> depending
// of used OutputType in save options provided
var resultPaths = conversionHandler.Convert<IList<string>>(sourceFileName, saveOptions);


foreach(var path in resultPaths) {
  Console.WriteLine("{0}", path);
}
Console.ReadLine();
 

How to place watermark in converted document

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);
// Save options
SaveOptions saveOptions = new PdfSaveOptions
{
    OutputType = OutputType.String,
    WatermarkOptions = new WatermarkOptions("Watermark text")
    {
        Color = Color.Blue,
        Font = new Font("Arial", 40),
        RotationAngle = 45,
        Transparency = 0.1,
        Left = 200,
        Top = 400
    }
};
var result = conversionHandler.Convert<string>(sourceFileName, saveOptions);
Console.WriteLine("The conversion finished. The result can be located here: {0}. Press <<ENTER>> to exit.", resultPath);
Console.ReadLine();
 

How to convert from and to PSD

Convert to PSD
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);

// Save options
SaveOptions saveOptions = new ImageSaveOptions
{
    OutputType = OutputType.String,
    ConvertFileType = ImageSaveOptions.ImageFileType.Psd,
    PsdOptions = new PsdOptions
    {
        ColorMode = PsdOptions.ColorModes.Grayscale,
        CompressionMethod = PsdOptions.CompressionMethods.Raw
    }
};
var result = conversionHandler.Convert<IList<string>>(sourceFileName , saveOptions);
 
Convert from PSD
const string sourceFileName = "sample.psd"; //TODO: Put the source filename here
// Setup Conversion configuration
var conversionConfig = new ConversionConfig
{
    CachePath = "cache",
    StoragePath = "."
};
var conversionHandler = new ConversionHandler(conversionConfig);

// Save options
SaveOptions saveOptions = new PdfSaveOptions
{
    OutputType = OutputType.String
};
var result = conversionHandler.Convert<string>(sourceFileName , saveOptions);
 

How to use ConversionStart, ConversionProgress and ConversionComplete events

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.ConversionStart += delegate(ConversionStartEventArgs args)
{
    Console.WriteLine("Conversion {0} started", args.ConversionGuid);
};
conversionHandler.ConversionProgress += delegate(ConversionProgressEventArgs args)
{
    Console.WriteLine("Conversion {0} progress: {1} %", args.ConversionGuid, args.Progress);
};
conversionHandler.ConversionComplete += delegate(ConversionCompleteEventArgs args)
{
    Console.WriteLine("Conversion {0} completed", args.ConversionGuid);
    Console.WriteLine("Result document is {0}. Cache is {1}", args.ConversionType, args.UsedCache?"used": "not used");
    Console.WriteLine("Result document has {0} page(s).", ((PdfConversionCompleteEventArgs)args).PageCount);
};
// Save options
SaveOptions saveOptions = new PdfSaveOptions
{
    OutputType = OutputType.String
};
var result = conversionHandler.Convert<string>(sourceFileName, saveOptions);
 

How to use IConversionProgressListener and IConversionStatusListener to receive conversion status changes and progress info

Defining conversion callbacks receiver

public class ConversionManager : IConversionProgressListener, IConversionStatusListener
{
    private readonly ConversionHandler _conversionHandler;
    public ConversionManager(string path)
    {
        var conversionConfig = new ConversionConfig { StoragePath = path };
        _conversionHandler = new ConversionHandler(conversionConfig);
        _conversionHandler.SetConversionProgressListener(this);
        _conversionHandler.SetConversionStatusListener(this);
    }
    public void ConversionProgressChanged(ConversionProgressEventArgs args)
    {
        Console.WriteLine("Conversion progress: {0} %", args.Progress);
    }
    public void ConversionStatusChanged(ConversionEventArgs args)
    {
        Console.WriteLine("Conversion status changed to: {0}", args.Status);
    }
    public string Convert(string file)
    {
        var option = new PdfSaveOptions
        {
            OutputType = OutputType.String
        };
        return _conversionHandler.Convert<string>(file, option);
    }
}
 

Usage of the conversion callback receiver for getting updates from conversion

const string sourceFileName = "sample.xlsx"; //TODO: Put the source filename here
// Setup Conversion configuration
var conversionConfig = new ConversionConfig
{
    CachePath = "cache",
    StoragePath = "."
};
var conversionHandler = new ConversionHandler(conversionConfig);

// Save options
SaveOptions saveOptions = new HtmlSaveOptions
{
    OutputType = OutputType.String,
    ShowGridLines = true
};

var result = conversionHandler.Convert<string>(sourceFileName, saveOptions);
 

How to show grid lines when converting from Excel

const string sourceFileName = "sample.xlsx"; //TODO: Put the source filename here
// Setup Conversion configuration
var conversionConfig = new ConversionConfig
{
    CachePath = "cache",
    StoragePath = "."
};
var conversionHandler = new ConversionHandler(conversionConfig);

// Save options
SaveOptions saveOptions = new HtmlSaveOptions
{
    OutputType = OutputType.String,
    ShowGridLines = true
};

var result = conversionHandler.Convert<string>(sourceFileName, saveOptions);
 

How to show hidden sheets when converting from Excel

const string sourceFileName = "sample.xlsx"; //TODO: Put the source filename here
// Setup Conversion configuration
var conversionConfig = new ConversionConfig
{
    CachePath = "cache",
    StoragePath = "."
};
var conversionHandler = new ConversionHandler(conversionConfig);

// Save options
SaveOptions saveOptions = new HtmlSaveOptions
{
    OutputType = OutputType.String,
    ShowHiddenSheets = true
};

var result = conversionHandler.Convert<string>(sourceFileName, saveOptions);