Click or drag to resize
TextExtensionsToMathML Method
Returns a string containing the W3C MathML (MML) markup for the math text in the range.

Namespace: TextObjectModel
Assembly: ManagedTOM2 (in ManagedTOM2.dll) Version: 1.0.5577.41188
Syntax
public static string ToMathML(
	this TextRange range
)

Parameters

range
Type: TextObjectModelTextRange
The range containing the math text.

Return Value

Type: String
A string containing the MathML markup.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type TextRange. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
NotSupportedException Microsoft Office is not installed, or the XSL stylesheet (used in the conversion process) was not found.
Remarks

This method works by transforming the OMML representation of the math text to MathML via an XSL stylesheet included with Microsoft Office. This method cannot be used if Microsoft Office is not installed.

Note: If the current process is 32-bit and only the 64-bit version of Office is installed, MathML conversion will be unavailable.

Examples
The following example demonstrates how to build-up math text and then convert it to MathML:
C#
using (RichTextBoxEx rtb = new RichTextBoxEx()) {
    TextDocument doc = TextDocument.FromRichTextBox(rtb);

    TextRange range = doc.EntireRange;
    range.Text = "(a+b/c)/(u+x/y)";
    range.BuildUpMath();

    Console.WriteLine(range.ToMathML());
}
See Also