Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# .net converting HTML to RTF [closed]

Tags:

html

c#

rtf

Theres another post at HTML to RTF Converter for .NET, but are there any open source converters or tutorials? I don't want to use Sautinsoft. I think there is a solution at ExpertsExchange, but I have to pay for that. Most of the search results on google point to an RTF to html converter, but not a html to RTF converter.

like image 979
qazqwerty555 Avatar asked May 07 '11 16:05

qazqwerty555


1 Answers

Create a WebBrowser. Load it with the html content. Select all and copy from it. Paste into a richtextbox. Then you have the RTF

string html = "...."; // html content
RichTextBox rtbTemp = new RichTextBox();
WebBrowser wb = new WebBrowser();
wb.Navigate("about:blank");

wb.Document.Write(html);
wb.Document.ExecCommand("SelectAll", false, null);
wb.Document.ExecCommand("Copy", false, null);

rtbTemp.SelectAll();
rtbTemp.Paste();

Now rtbTemp.RTF has the RTF converted from the HTML.

like image 136
Jerry Avatar answered Sep 28 '22 07:09

Jerry