Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Thu Oct 05, 2017 2:53 pm

We are attempting to use v2.16 of Spire Office to process email attachments. The render function for a Slide Presentation is shown below.
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?

pgerard
 
Posts: 2
Joined: Thu Jul 06, 2017 3:57 pm

Fri Oct 06, 2017 5:03 am

Hello,

Thanks for your feedback. Please confirm if it is the ppt document stream, if so, please provide the detailed about how you get the stream you were using.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Oct 06, 2017 8:52 am

The stream is being decoded from a MimePart object (part of the MimeKit library)
Code: Select all
MimePart attachment;
...
var attachmentStream = new MemoryStream();
attachment.ContentObject.DecodeTo(attachmentStream);


The file that is being temporarily written to disk has been compared with the original PPT file being sent as an attachment, it was found to be the same at a binary level.

pgerard
 
Posts: 2
Joined: Thu Jul 06, 2017 3:57 pm

Fri Oct 06, 2017 10:12 am

Hello,

Thanks for your response. I suppose the stream may be not match the MS powerpoint standard, so our product can't detect it as a ppt object, could you send the stream value to us for investigation further?

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon Oct 09, 2017 10:08 am

Hello,

Greetings from E-iceblue.
Did you resolve the issue? If not, please attach the stream value for us investigation further.
Thanks in advance for your valuable feedback and time.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Wed Apr 22, 2020 1:30 pm

Hi,

Face the same issue with reading PPTX from stream.

Here is the part of the code

Code: Select all
                 
                            using (var file = new MemoryStream())
                            {
                                var (folderName, fileName) = ExtractFileNameAndFolder(input.FileName);
                                await _storageEngine.DownloadToStreamAsync(folderName, fileName, file);
                                using (var srcPresentation = new Presentation(file, FileFormat.Auto))
                                {
                                   Some functionality...
                                }
                             }

daedroth
 
Posts: 1
Joined: Wed Apr 22, 2020 1:23 pm

Thu Apr 23, 2020 1:26 am

Hi Davyd,

Thanks for your inquiry.
To help us investigate your issue more accurately and quickly, please share your input file with us. You could upload here or send it to us(support@e-iceblue.com) via email. Thanks in advance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Tue Apr 28, 2020 8:15 am

Hi Davyd,

Greetings from E-iceblue!
How is your issue now? Could you please provide input file to help us investigate further?
Thanks in advance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Wed Dec 16, 2020 6:56 am

Hello,
In my scenario, I set the position of my stream to 0. This fixed my issue.
I hope it will fix your issue as well :wink: .

Support,
In this method "LoadFromStream", can you guys set the position of the stream to 0 from your code.

selvakumar94
 
Posts: 1
Joined: Wed Dec 16, 2020 6:47 am

Wed Dec 16, 2020 9:30 am

selvakumar94 wrote:Hello,
In my scenario, I set the position of my stream to 0. This fixed my issue.
I hope it will fix your issue as well :wink: .

Support,
In this method "LoadFromStream", can you guys set the position of the stream to 0 from your code.


Hello,

Thanks for sharing your workaround.
If you encounter any problems related to our products in the future, just feel free to contact us!

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.Presentation