views:

990

answers:

3

Can Windows Presentation Foundation read/write WMF/EMF files without having to use WinForms Interop or Win32.

If it does not, what is the reason?

+3  A: 

A quick search on MSDN reveals a thread containing a post by Peggi Goodwin, a PM at Microsoft:

WPF does not support the EMF and WMF image formats. These formats are more susceptible to security vulnerabilities than other image formats, so we do not intend to support them.

Robert Macnee
Yes, thanks Robert. I had noticed the same thread and couldn't quite believe that security vulnerabilities would simply destroy support for these file formats without their being replaced by another format.
We've been upgrading our WinForms application to use WPF and have run into the same issues with metafile support, which we use for copy-paste into Office products.Currently we translate from XAML to metafile by hand for it (after converting our complex XAML to simple Paths and Glyphs using XPS).
Robert Macnee
A: 

I did it !!!

I'm using ComponentOne's WPF chart in my real code but to keep the example simple I just did a button. But it DOES work on Complex wpf widgets. Fonts, Transparency, AntiAlias etc. everything works. And I can paste into Word and change Labels on Charts etc.

Basically I decimate the XAML to XPS then import it Back into XAML.

Then I uses an open source project that converts XAML to WMF called XAMLToys.

XAMLToys would fail 99% of the time because you could not serial complex XAML objects

http://softronix.com/download/WpfToWmfClipboard.zip

Big Kudo's to these two projects

I'm only allowed one Link :(

h t t p://xamltoys.codeplex.com/

h t t p://khason.net/blog/converting-fixeddocument-xpsdocument-too-to-flowdocument/

A: 

Hi user269038. Thanks for your solution! It seems to work as charm except that i get all the texts as paths and not as strings that could be edited in Word/PPT etc.

The fact that all the texts will get copied as vector grafics makes the final Word/PPT-documents very large in file size (especially if there are loads of text to be copied). Have you had the same problems? Do you happened to know any solutions?

Antti