Convert PowerPoint to HTML

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”

About these ads

About amitpatelit
Having more than 9 years of experience in IT industry. - Strong knowledge and experience on various technologies and tools like ASP.NET, MVC, Entity framework, Razor,VB.NET, C#, WCF,WPF, MVC, Silver light, ASP, XML ,Java Script, HTML, CSS, AJAX, COM/DCOM,MS SQL Server, Enterprise Library, MSMQ, SQL Server Reporting Service, Crystal Reports. - Achieved 7800 points (Star level) in the official Microsoft ASP.NET forum. - MCPD and MCTS in Web, Window and distributed application.

6 Responses to Convert PowerPoint to HTML

  1. Neel Kamal says:

    You can write this in single line as given bellow.

    new Microsoft.Office.Interop.PowerPoint.Application().oApplication.Presentations.Open(strSourceFile).oPresentation.SaveAs(strDestinationFile, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsHTML);

  2. Neel kamal says:

    Write this simple code for this

    POWERPOINT.Application App = new Microsoft.Office.Interop.PowerPoint.Application();

    POWERPOINT.Presentation pres = App.Presentations.Open(fileName, OFFICECORE.MsoTriState.msoTrue, OFFICECORE.MsoTriState.msoFalse, OFFICECORE.MsoTriState.msoFalse);
    int pageNo = 0;

    pres.SaveAs(imagePath + “\Images”, POWERPOINT.PpSaveAsFileType.ppSaveAsPNG, OFFICECORE.MsoTriState.msoFalse);

    //you need to add references and namespaces as

    using POWERPOINT = Microsoft.Office.Interop.PowerPoint;
    using OFFICECORE = Microsoft.Office.Core;

  3. Adarsh says:

    is there any code in php to convert ppt to html

  4. You can convert PPT or PPTX to Image using Aspose.Slide for .NET API. Try it i hope you will find it useful also.

    http://www.aspose.com/.net/powerpoint-component.aspx

  5. Penny D'Costa says:

    You can convert PPT or PPTX to image format using C#/.NET Library for Powerpoint like Aspose.slide for .NET. I am using it and very much satisfied with the results it has produced. Try it:

    http://www.aspose.com/.net/powerpoint-component.aspx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 239 other followers

%d bloggers like this: