Friday, July 30, 2010

Presentation to png converter

For all those who have waited to have an application that converts .ppt files to .png in bulk and extract the notes from it into a .csv file.....

here you go...

Wednesday, July 28, 2010

How to convert PPT slides into image files in WPF




Step1: Create a WPF application in Visual Studio 2010 and add references
i)Microsoft Office 11.0 Object Library
ii)Microsoft PowerPoint 11.0 Object Library .


Step2: Add the following code in the XAML file:

Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="PPT to Image conversion" Height="350" Width="525"

Grid
Button Width="200" Height="200" Content="Generate Images from PPT" Click="Button_Click"

/Button
/Grid
/Window

Step3: Add the following code in your MainWindow.xaml.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;

namespace WpfApplication1
{
///
/// Interaction logic for MainWindow.xaml
///

public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

}

private void Button_Click(object sender, RoutedEventArgs e)
{
string filepathToImage = @"path to image.png";
string filepathToPPT = @"path to presentation.ppt";
Microsoft.Office.Interop.PowerPoint.Application presentationApplication = new Microsoft.Office.Interop.PowerPoint.Application();
Presentation ppt = presentationApplication .Presentations.Open(filepathToPPT , MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
ppt.Slides[1].Export(filepathToImage , "png", 1024, 768);
}
}
}

Step 4: Run the application and click the button to see the image generated in the location you specified in the "filepathToImage" variable.
You can do the same for batch conversion by modifying the code accordingly.