Create EMF with rotated text that is editable in office

T

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.ReleaseHdc(hdc);
g.Dispose();
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);
g.Dispose();

Can anyone tell me how I can draw rotated text without loosing the editing
capability?
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.

Cheers,
Tilo
 
B

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
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

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

TiPiX

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

Top