7

I am using Office 07 PIA to convert the ppt into images in C#.

The slides are properly converted into images.

Now, while individual slides are converted into images, I was hoping for a workaround that could also convert the animations within slides too. I want to play these ppt [converted to images] in my custom application and not in MS PowerPoint.

I would really appreciate any help!

Thanks

Jayesh
  • 3,891
  • 11
  • 55
  • 83

3 Answers3

12

It's pretty simple:

Office 2002

using Microsoft.Office.Core;
using PowerPoint;

ApplicationClass pptApplication = new ApplicationClass();

Presentation pptPresentation = pptApplication.Presentations.Open("myfile.ppt", MsoTriState.msoFalse,
MsoTriState.msoFalse, MsoTriState.msoFalse);

pptPresentation.Slides.Item(1).Export("slide.jpg", "jpg", 320, 240);

Office 2003

using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;

ApplicationClass pptApplication = new ApplicationClass();
Presentation pptPresentation = pptApplication.Presentations.Open("myfile.ppt", MsoTriState.msoFalse,
MsoTriState.msoFalse, MsoTriState.msoFalse);

pptPresentation.Slides.Item[1].Export("slide.jpg", "jpg", 320, 240);

Image Output Quality

pptPresentation.Slides.Item[1].Export("slide.png", "PNG", 1024, 768);
Lukas Šalkauskas
  • 14,191
  • 20
  • 61
  • 77
  • this would just convert the slides into images, right? I also want to convert the animations within the slides to some presentable format. – Jayesh Jun 04 '10 at 08:05
  • yes, hmm i don't know what about animations, maybe it will split animations to different images, need to test, but this is functionality which provided to us by MS, any other functionality we should create by our selves :/ – Lukas Šalkauskas Jun 04 '10 at 08:56
  • I have tested, it does not create images for animations. Yes, we need to do the "extra" functionalities ourselves and thus I am asking for some leads in to going about it. I'm doing this for a college project. – Jayesh Jun 04 '10 at 09:03
  • also it's possible to convert it to flash, and then you should have possibility to reflect animation in a nice way. Here is an free trial SDK: http://www.ispringsolutions.com/products/ispring_sdk.html – Lukas Šalkauskas Jun 04 '10 at 09:42
  • also there is a way to catch events, so maybe they could help you in some way: http://support.microsoft.com/?kbid=308825 – Lukas Šalkauskas Jun 04 '10 at 09:50
  • I shall check out the KB. Thanks mate :) – Jayesh Jun 04 '10 at 10:41
  • so this requires office to be installed on server, and lots of other configurations. i posted it here stackoverflow.com/a/40385136/1386991 – Abhimanyu Apr 30 '17 at 12:55
  • From my understanding this will also cause an "Insufficient memory to continue the execution of the program" exception if running as a service or unattended. As "Microsoft does not currently recommend and does not support automation of MS Office applications" > See [link](https://stackoverflow.com/questions/42083799/insufficient-memory-exception-in-interop-library-when-exporting-images-of-ppt-sl) – John Grabanski Sep 28 '22 at 19:56
3

The question is difficult to understand.

However from what I gather you are trying to display PowerPoint Slides in your custom C# Application?

Solution 1:

Convert each PPT slide into HTML format (this should be possible from PowerPoint e.g. save as).

Drop a web-Browser component onto your application, and then simply point to the HTML file(s). You could even get the 'next' abd 'prev' buttons to go to the next 'slide' or bind it to mouse click.

As for videos, I'm not sure how exporting HTML from PowerPoint would handle this, you may be able to convert the Video to FLV, and imbed a basic FLV flash player into the HTML 'slide' file(s)

Extended Solution 1:

To deal with the animations (PowerPoint Fades etc) you could use this free product iSpring. This converts PPT to Flash (including animations and videos I believe). Which can then be embedded into a HTML file and played back on a web browser Component.

Edit 2: iSpring is no longer free

Darknight
  • 2,460
  • 2
  • 22
  • 26
  • See, I have a Picture Box that displays the ppt slides that are converted into images. Now the animations within the slides are not accounted for in this process. I was hunting for a workaround for the same! – Jayesh Jun 04 '10 at 08:07
  • Are you talking about PowerPoint Animations (e.g. transitions/fades etc?) or video animations? – Darknight Jun 04 '10 at 08:24
  • Yes, I am talking about the PowerPoint Animations. – Jayesh Jun 04 '10 at 08:33
  • Actually I am creating the images from slides at runtime, so want to do stuff programmatically. anyways thanks for the link. – Jayesh Jun 04 '10 at 08:47
  • 4
    @Darknight: iSpringFree is still free, it's just at a different URL: http://www.ispringfree.com/ – Todd Main Jun 04 '10 at 16:12
0

you need to set this properties for this

-Right click package- Interop, in the solution explorer under your project References. -Click properties. -And there should be the option there for Embed Interop Assembly. -Set it to False

Code-

FileInfo objfile = new FileInfo(FileUpload1.PostedFile.FileName);
if (objfile.Extension.Equals(".pptx"))
{
    ApplicationClass pptApplication = new ApplicationClass();
    Presentation pptPresentation = pptApplication.Presentations.Open(objfile.FullName, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
    pptPresentation.Export(objfile.FullName, "jpg", Int32.Parse(pptPresentation.SlideMaster.Width.ToString()), Int32.Parse(pptPresentation.SlideMaster.Height.ToString()));
}
Frederik Hoeft
  • 1,177
  • 1
  • 13
  • 37
Rohan
  • 41
  • 2