10

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?

skaffman
  • 398,947
  • 96
  • 818
  • 769
user62572
  • 1,388
  • 2
  • 15
  • 24

2 Answers2

9

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
  • 11,650
  • 4
  • 40
  • 35
  • 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. – user62572 Feb 16 '09 at 22:10
  • 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 Feb 16 '09 at 23:47
0

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 used an open source project that converts XAML to WMF called XAMLToys.

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

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

Big kudos to these two projects

http://xamltoys.codeplex.com/

http://khason.net/blog/converting-fixeddocument-xpsdocument-too-to-flowdocument/

jess
  • 254
  • 3
  • 13