Create EMF with rotated text that is editable in office


Tilo Pätzold

Hi Everybody (especially Microsoft),

we build EMF files with rotated text for export to office (powerpoint,
word). It is planned that the text can be edited in the office document.
Without the rotate transformation the text stays as a block and can be
edited in the office document after ungrouping. But a rotated text leads to
single charackters when ungrouping.
The following sample code creates an emf file. The file can be dragged to
powerpoint to see the problem.

Bitmap bmp = new Bitmap(100, 100, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bmp);
IntPtr hdc = g.GetHdc();
Metafile mf = new Metafile(@"test.emf", hdc);
g = Graphics.FromImage(mf);
g.RotateTransform(30.0f); // Leads to single charackters in the Emf file
String s = "1.2345";
g.DrawString(s, this.Font, Brushes.Red, 0, 0);

Can anyone tell me how I can draw rotated text without loosing the editing
There must be a way. Because when I make a rotated text area in power point
and save this to an emf picture it can be imported without loosing editing
capability. I already enumerated the metafile to find out the record types.
But that does not tell me which gdi methods I have to use.

Thank you.


Bob Powell [MVP]

Try specifying that the metafile can use both EMF and enhanced EMF (with
GDI+ commands).

Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting

Find great Windows Forms articles in Windows Forms Tips and Tricks

Answer those GDI+ questions with the GDI+ FAQ

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


Good idea. I tried all types.
Both EmfType.EmfOnly and EmfType.EmfPlusDual result in single
charackter blocks when ungrouping.
EmfType.EmfPlusOnly results in an empty graphic when ungrouping.
Unfortunately no type gives a satisfying result.
Our Office version is 2003 SP2.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question