Quantcast
Channel: amitpatelit » .NET
Viewing all articles
Browse latest Browse all 11

Convert PowerPoint to HTML

$
0
0

Hello friends,

This post is explain about how to convert ppt file in html pages by asp.net application. A requirement comes like when user will provide ppt with attached set of images and asp.net application needs to convert it in html pages where images needs to find from ppt and save in one folder and attached with html pages, so html page desing looks like same as ppt.

To implement this I have used MS office atomization tool (DCOM). I have added below dll from .net references.
Microsfot.Office.Core
Microsfot.Office.Interop.PowerPoint

In MS Power Point has inbuild functionality available to : File> Save as Web Pages. So I have used the same functionality by .net code from Powerpoint compenent.

Below are the code I have implemented to achieve this.

string strSourceFile = @"D:\PPT_Presentation.pptx";
            //Give the name and path of the HTML file to be generated
            string strDestinationFile = @"D:\HTML_Presentation.htm";
            //Create a PowerPoint Application Object

            Microsoft.Office.Interop.PowerPoint.Application oApplication = new Microsoft.Office.Interop.PowerPoint.Application();

            //Create a PowerPoint Presentation object

            Microsoft.Office.Interop.PowerPoint.Presentation oPresentation = oApplication.Presentations.Open(strSourceFile);
            //Call the SaveAs method of Presentaion object and specify the format as HTML
            oPresentation.SaveAs(strDestinationFile, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsHTML);

            //Close the Presentation object
            oPresentation.Close();
            //Close the Application object
            oApplication.Quit();

So once you will run the application there will be one html file created which you provided as destination file and one folder created with same name at same location with all required supported files.

Requirement to run this code:
Microsoft office should be installed on the system
Microsoft office Power Point DCOM configured with application user with proper access.

Note: Use direct component is not suggested by Microsoft, due to performance and reliability issue.
http://support.microsoft.com/kb/257757/en-us
So to achieve this scenario Microsoft suggests Office open xml format.
http://msdn.microsoft.com/en-us/library/bb332059(v=office.12).aspx

Please contact me at amitpatel.it@gmail.com for more any other information.

Thanks,
Amit Patel
“Enjoy Programming”



Viewing all articles
Browse latest Browse all 11

Trending Articles