Convert Selected PowerPoint Shapes (or DrawingML) to XAML

I need to convert selected PowerPoint shapes to XAML so I can effectively place an equivalent vector-based shape inside my WPF app (the XAML end result has to be scalable - converting to an image defeats the purpose of what I'm trying to do).

I'm open to a variety of ways to accomplish this, including writing a PowerPoint addin (if this could get me access to the bezier point coordinates of the selected shapes in PowerPoint). I'm not familiar enough with PowerPoint addins to know if this is possible or not.

My first approach was to copy the PowerPoint shapes to the clipboard, and then convert the clipboard contents to objects I can understand and then generate the XAML from there. If I do this I can get to the DrawingML representation (through the Art::GVML ClipFormat), but it's unclear how to easily convert that DrawingML to XAML (looks like weeks of error-prone work to create from scratch).

There are other formats available on the clipboard (EMF, System.Drawing.Imaging.Metafile, PowerPoint 12.0 Internal Shapes), but they all appear to be dead ends.

Any suggestions?


You can try this:

Powerpoint Shape to WMF

Microsoft.Office.Interop.PowerPoint.Application app = new Microsoft.Office.Interop.PowerPoint.Application();
var pps = app.Presentations;
string d ="filepath.pptx";
Presentation ppt = pps.Open(d, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
for (int j = 1; j < ppt.Slides.Count; j++)
    Slide sld = ppt.Slides[j];
    List<Microsoft.Office.Interop.PowerPoint.Shape> shapes = new List<Microsoft.Office.Interop.PowerPoint.Shape>();
    for (int k = 1; k < sld.Shapes.Count; k++)
        Microsoft.Office.Interop.PowerPoint.Shape shape = sld.Shapes[k]; 
        shape.Export("outputFilePath.wmf", PpShapeFormat.ppShapeFormatWMF);

then WMF to XAML: Microsoft Forum:

1) Check out and it's related project These are EMF/WMF readers for WPF. You'd write a simple utility to read in the images and write them back out again. I've played with them a little and had pretty good luck with them. If they'll work for you, this would be my first choice. You'll need to test them of course. Conversions like this are never perfect due to difference in design between the various formats so make sure you're not using something that's not supported in the converter.

2) Another project I ran into was I haven't played with it, but you might give it a look.

3) If the direct route doesn't work, you might consider converting the WMF files to a different vector format like SVG and then converting that SVG file to XAML. There are lots of tools for EMF/WMF to SVG conversion. For the SVG to XAML conversion you can look at and I doubt this will work as well as a direct conversion, but you never know.

About PowerPoint Add-ins and Running the above example you need Microsoft Office Interop libraries.

Need Your Help

Problems with Embedded Functions within Simulink

matlab simulink matlab-coder

I'm trying to simulate a very simple model using an embedded matlab function that takes the input and add's 10 to the value using a constant block that inputs into the matlab function, which then o...

NSEntityDescription Not found

objective-c core-data

I have a CoreData database which works on the root view controller. I have a second UIViewController of which when I switch to, and use the same exact line to fetch NSEntityDescription, I get the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.