Previously known as TOM Classes for .NET
A managed wrapper for the Text Object Model (TOM/TOM2).
ManagedTOM is a managed assembly, written in C++/CLI, that provides a set of wrapper classes for the Text Object Model (TOM) interfaces. This allows .NET developers to access the functionality of the native ITextDocument interface without the need to use dynamic programming or COM interop. The assembly includes the following classes:
TextDocument(ITextDocument)TextRange(ITextRange)TextSelection(ITextSelection)TextFont(ITextFont)TextPara(ITextPara)TextStoryRanges(ITextStoryRanges)
The Text Object Model exposes some additional features when compared to working directly with a RichTextBox control in Windows Forms, as well as offering better performance when manipulating documents.
The latest version includes support for TOM 2 (available on Windows 8 and higher). Each of the above classes wraps both the TOM 1 and TOM 2 interfaces (e.g. ITextDocument and ITextDocument2), and will automatically select the best available version. In addition, TOM 2 adds the following classes:
TextStory(ITextStory)TextRow(ITextRow)TextStrings(ITextStrings)
RichTextBoxEx– an extended version of the Windows FormsRichTextBoxcontrol which automatically loads the newest available version of the native RichEdit control (required for advanced functionality).TextExtensions– provides extension methods for working with ranges using a more familiar syntax, as well as conversion of math text to OMML and MathML.
- .NET Framework 4.8
- Windows Vista or higher
- Visual C++ Redistributable for Visual Studio v14
- If you don't want to build from source, download the binaries for the latest release.
- To use the TOM classes in your code, simply reference the
ManagedTOM2.dllassembly (x86 or x64) in your project. - IntelliSense documentation is included, as well as a compiled help (
.chm) file for easy API reference.
- What are the requirements for accessing the TOM2 functionality?
You must obtain theTextDocumentobject from a RICHEDIT50W control. This control ships with Windows 8 and newer, however the Windows FormsRichTextBoxcontrol will only use RICHEDIT20W by default. Use the includedRichTextBoxExcontrol to load the newer version. - Why does
TextRange.ToMathML()throw aNotSupportedException?
This method requires theTextDocumentobject to be obtained from the RICHEDIT60W control included with Microsoft Office. - Why is a
BadImageFormatExceptionthrown when trying to load the assembly?
The processor architecture of the entry assembly must match that of theManagedTOM2.dllassembly. You can build it for x86 or x64, but I advise against using 'Any CPU' as this could behave differently at run-time.