Load any file for conversion from a stream in C#

More...

To load and convert any file from a stream object to a different file type, use the LoadFromStream method from the GdPictureDocumentConverter class. This method requires the following parameters:

  • Stream — The stream object of any file.
  • DocumentFormat — The file format represented as a member of the DocumentFormat enumeration.

The list of supported files is available on the Supported File Types page.

To load and convert an Excel file from a stream object, use the following code:

// Create a stream object from an Excel file.
using Stream streamFile = new FileStream(@"C:\temp\source.xlsx", FileMode.Open);
// Create a new `gdpictureDocumentConverter` object.
using GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter();
// Specify the file format.
GdPicture14.DocumentFormat format = GdPicture14.DocumentFormat.DocumentFormatXLSX;
// Load the stream object to the `gdpictureDocumentConverter` object.
gdpictureDocumentConverter.LoadFromStream(streamFile, format);
gdpictureDocumentConverter.SaveAsPDF(@"C:\temp\output.pdf");