Power point Presentation to XAML converter

Draft for converting the presentationXML to XAML

I used OpenXML SDK 2.0, which you can install from


The namespaces, classes, methods and properties corresponding to this SDK is available at


Sample code:-

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
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.Imaging;
using System.Windows.Navigation;
using System.Windows.Forms;
using System.Xml;
using System.Data;
using System.IO.Packaging;
using System.IO;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Presentation;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Drawing;

namespace Office_To_Xaml

/// Interaction logic for Window1.xaml

public partial class Window1 : Window
static StringBuilder xamlBuilder ;
static StringWriter xamlWriter;
public Window1()
private void SelectFile_Click(object sender, RoutedEventArgs e)
OpenFileDialog officeFile = new OpenFileDialog();
OfficeFilePath.Text = officeFile.FileName;
private void convertToXaml_Click(object sender, RoutedEventArgs e)
xamlBuilder = new StringBuilder();
xamlWriter = new StringWriter(xamlBuilder);
string presentationFile = OfficeFilePath.Text;
// Open the presentation as read-only.
using (PresentationDocument presentationDocument = PresentationDocument.Open(presentationFile, false))
public void GetSlides(PresentationDocument presentationDocument)
// Verify that the presentation document exists.
if (presentationDocument == null)
throw new ArgumentNullException(“presentationDocument”);
// Get the presentation part.
PresentationPart presentationPart = presentationDocument.PresentationPart;
// Verify that the presentation part and presentation exist.
if (presentationPart != null && presentationPart.Presentation != null)
// Get the Presentation object from the presentation part.
Presentation presentation = presentationPart.Presentation;
// Verify that the slide ID list exists.
if (presentation.SlideIdList != null)
// Get the collection of slide IDs from the slide ID list.
var slideIds = presentation.SlideIdList.ChildElements;
for (int slideIndex = 0; slideIndex < slideIds.Count; slideIndex++)
// Get the relationship ID of the slide.
string slidePartRelationshipId = (slideIds[slideIndex] as SlideId).RelationshipId;
// Get the specified slide part from the relationship ID.
SlidePart slidePart = (SlidePart)presentationPart.GetPartById(slidePartRelationshipId);
// Pass the slide part to the next method, and
// then return the array of strings that method
xamlWriter.WriteLine(” Slide: ” + slideIndex +1);
public void GetDataInSlide(SlidePart slidePart)
string data = “”;
// Verify that the slide part exists.
if (slidePart == null)
throw new ArgumentNullException(“slidePart”);
string bgcolor = “white”;
if (slidePart.Slide.CommonSlideData.Background != null)
BackgroundProperties bgProperties = slidePart.Slide.CommonSlideData.Background.BackgroundProperties;
DocumentFormat.OpenXml.Drawing.SolidFill fillColor = bgProperties.GetFirstChild();
if (fillColor != null)
bgcolor = ((fillColor).RgbColorModelHex).Val;
// If the slide exists…
if (slidePart.Slide != null)
// Iterate through all the paragraphs in the slide.
foreach (DocumentFormat.OpenXml.Drawing.Paragraph paragraph in slidePart.Slide.Descendants())
data = “”;
foreach (var text in paragraph.Descendants())
data+=text.Text+” “;
DocumentFormat.OpenXml.Drawing.Run run = null;
RunProperties runProperties = null;
if (paragraph.ChildElements.Count > 0)
run = paragraph.GetFirstChild();
if (paragraph.ChildElements.Count > 0 && run!=null)
runProperties = run.RunProperties;
bool bold=false, italic=false;
int fontSize = 3200;
string fontColor = “black”;
if (run != null)
if (runProperties.FontSize != null)
fontSize = runProperties.FontSize;
if (runProperties.Bold != null)
bold = runProperties.Bold;
if (runProperties.Italic != null)
italic = runProperties.Italic;
DocumentFormat.OpenXml.Drawing.SolidFill textColor = runProperties.GetFirstChild();
if (textColor != null && ((textColor).RgbColorModelHex)!=null)
fontColor = ((textColor).RgbColorModelHex).Val;
string fontStyle=””;
fontStyle+=” FontStyle=\”italic\””;
xamlWriter.WriteLine(“” + data+ “”);

About ambilykk

I am a Technology Evangelist on Microsoft Technologies. I am carrying the passion on Microsoft technologies specifically on web technologies such as ASP .Net and Ajax. My interests also include Azure and Visual Studio. Technology adoption and learning is my key strength and technology sharing is my passion.
This entry was posted in Uncategorized. Bookmark the permalink.

1 Response to Power point Presentation to XAML converter

  1. Can I have application above (source code and file) and bit more information about that

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 )

Connecting to %s