سؤال

I have a problem with umlauts on characters when using openxml. Every char in the string is in Arial, but the ä is in Calibri. I really dont know why.

Can someone help me?

this is my code:

        DocumentFormat.OpenXml.Wordprocessing.Run run = new DocumentFormat.OpenXml.Wordprocessing.Run();

        RunProperties runProp = new RunProperties(); // Create run properties.
        RunFonts runFont = new RunFonts();           // Create font
        runFont.Ascii = "Arial";                     // Specify font family

        runProp.Append(runFont);

        run.Append(runProp);
        run.Append(new Text("Kapazität"));
هل كانت مفيدة؟

المحلول

You need to specify the HighAnsi property of the RunFonts object.

runFont.HighAnsi = "Arial";

As you would expect, Ascii font designation only accounts for ASCII characters (and a very short range of Unicode U+0000-U+007F). The umlaut characters are in the "extended" unicode range, and HighAnsi is responsible for most of that character set.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top