Download Free Wpf Convert Rtf To Xaml For Mac

Well, I have been playing with Avalon for a bit. One of the things that I have been playing with is a RSS viewer, just a little hobby. Viewing blogs were not difficult, but the displaying of the HTML from the RSS is where the problems start. But what you really need to do is use a converter and then. Trying to create WPF controls without XAML is asking for trouble - the whole framework is built around the MVVM pattern which demands that your View be described in a declarative fashion, rather than a procedural fashion.

Have you ever had the desire to convert some RTF text into HTML? Probably not. But if you do, then you are in luck! I recently had the need to do this conversion and after some searching found out a way to do it by enhancing a sample distributed in the MSDN library. The sample is called: XAML to HTML Conversion Demo.


The sample has code which converts HTML to and from a XAML Flow Document. But this doesn’t make things easier until you realize that there is a way to convert RTF to XAML easily. The key is to use System.Windows.Controls.RichTextBox which can load RTF from a stream and save it as XAML. This conversion is shown below:

Convert Rtf To Word Document

With this code we have all we need to convert RTF to HTML. I modified the sample to add this RTF To XAML conversation and then I run that XAML through HTML converter which results in the HTML text. I added an interface to these conversion utilities and converted the sample into a library so that I would be able to use it from other projects. Here is the interface:

Download Free Wpf Convert Rtf To Xaml For Mac

Download free wpf convert rtf to xaml for mac

Convert Rtf To Doc

With this I am now able to convert from RTF to HTML. However, there is one catch – the conversion uses the RichTextBox WPF control which requires a single threaded apartment (STA). Therefore in order to run your code that calls the ConvertRtfToHtml function, it must also be running in a STA. If you can’t have your program run in a STA then you must create a new STA thread to run the conversion. Like this: