RTF2HTML and Plain Text

Get technical support of RTF to HTML .Net in C# and VB.Net
Ryan
Posts: 2
Joined: Thu May 20, 2021 9:06 am
Contact:

RTF2HTML and Plain Text

Post by Ryan »

In the latest version (7.5.1.27) of your RtfToHtml component the following code:

Code: Select all

  var rtfToHtml = new RtfToHtml
            {
                Encoding = RtfToHtml.eEncoding.UTF_8,
                OutputFormat = RtfToHtml.eOutputFormat.Text
            };
rtfToHtml.ConvertFileToString(inpFile)

always creates html output? Is this a bug? E.g. in version 6 the output was in plain text.
Oliver
Posts: 24
Joined: Wed Aug 19, 2020 11:59 am
Contact:

Re: RTF2HTML and Plain Text

Post by Oliver »

Hi

Since v.7... for creating Text document, you need to use this string:

Code: Select all

r.ToText(outFiletxt);
For example: If you want to convert RTF to HTML

Code: Select all

r.ToHtml(outFiletxt);
Full code sample:

Code: Select all

string inpFile = @"Example.rtf";
string outFileHtml = @"Result.html";
string outFileTxt = @"Result.txt";
               r.OpenRtf(inpFile);
                r.ToHtml(outFileHtml);
                r.ToText(outFileTxt);
If you want to know more information about RTF to HTML .Net, here a lot of code samples: https://sautinsoft.com/products/rtf-to-html/examples/
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests