1

I able to export Power Point Slides into images to my local path by using Microsoft.Office.Interop.PowerPoint DLL's Presentation classes, below is my code,

  1. Is it possible to load that image into a Memory Stream instead of local storage?

  2. How to Overwrite/ extend Slide.Export() function to load that image into a memory stream.

    Microsoft.Office.Interop.PowerPoint.Application pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();
    
    Microsoft.Office.Interop.PowerPoint.Presentation pptPresentation = pptApplication.Presentations.Open2007(awsFilePath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
    
    foreach (Microsoft.Office.Interop.PowerPoint.Slide pptSlide in pptPresentation.Slides)
      {                                        
           pptSlide.Export(Server.MapPath("~/" + new Random().Next().ToString() + ".png"), "PNG", 1024, 768);
       }
    
sridharnetha
  • 2,104
  • 8
  • 35
  • 69
  • the [documentation for office 2013 and later](https://msdn.microsoft.com/en-us/library/office/ff746030.aspx) shows that there is no overload of `Slide.Export` that would take a stream instead of a file name. It is always written to a file. Could you export it to a temporary directory, then read into a stream from there, and delete the file afterwards? – Cee McSharpface May 24 '17 at 09:47
  • [related](https://stackoverflow.com/q/1321578/1132334) – Cee McSharpface May 24 '17 at 09:50
  • @dlatikay how to Overwrite/ extend existed function `Slide.Export()` but not `Overload` – sridharnetha May 24 '17 at 09:56
  • no way - it is implemented as unmanaged code inside PowerPoint.exe and called via COM interop. is it a requirement to absolutely not write to a file, also not if you clean it up immediately after streaming? – Cee McSharpface May 24 '17 at 09:59
  • there are tools/libraries which seem to be able to do what you need (google found me this for example, I'm not affilated): [PresentationSpire](https://www.e-iceblue.com/Tutorials/Spire.Presentation/Spire.Presentation-Program-Guide/Document-Operation/Save-PowerPoint-file-to-Stream-and-Load-PowerPoint-file-from-Stream.html) – Cee McSharpface May 24 '17 at 10:02
  • 1
    Just FYI: Using Office-Interop on a server is not supported by Microsoft, and in general it is also very prone to all kinds of errors. For more information on that subject see the following microsoft support article: [Considerations for server-side Automation of Office](https://support.microsoft.com/en-us/help/257757/considerations-for-server-side-automation-of-office) – bassfader May 24 '17 at 10:36

0 Answers0