- Code: Select all
private Image RenderPresentationImage(Stream content)
{
var presentation = new Presentation();
presentation.LoadFromStream(content, Spire.Presentation.FileFormat.Auto);
return presentation.Slides[0].SaveAsImage();
}
When it makes the call to LoadFromStream, an exception is thrown.
spr2955: Unknown file format.
at spr838.0()
at spr2444.2()
at spr2444.4()
at spr8845.0(Stream A_0)
at spr10317.0(Stream A_0)
at spr10317.2(Stream A_0)
at spr10317..ctor(Stream A_0, spr2020 A_1)
at Spire.Presentation.Presentation.LoadFromStream(Stream stream, FileFormat fileFormat)
at Common.DocumentPreview.DocumentPreviewFactory.RenderPresentationImage(Stream content)
Whilst investigating the problem we tried loading the input stream into a file on disk, then reading that instead.
- Code: Select all
private Image RenderPresentationImage(Stream content)
{
var filename = @".\temp.ppt";
using (var fileStream = File.Create(filename))
{
content.Seek(0, SeekOrigin.Begin);
content.CopyTo(fileStream);
}
var presentation = new Presentation();
presentation.LoadFromFile(filename);
return presentation.Slides[0].SaveAsImage();
}
This was successful, the first slide of the presentation was correctly rendered as an image.
We've tried several different PPT files, and are experiencing the same exception on each.
Could you suggest a solutions that does not require us to save the stream to disk before rendering it?