Closed 4g0st1n0 closed 6 years ago
The Rtf.ToHtml
method has an overload where you can pass in an XmlWriter
to which the HTML is written. This leaves you with a couple of options:
XmlWriter
classes designed to convert html to Markdown, Textile, and "plain text". (The Markdown writer should be more complete while the Textile writer has a few remaining issues.) Therefore, your code might look something like:using (var writer = new System.IO.StringWriter())
using (var markdown = new BracketPipe.MarkdownWriter(writer))
{
Rtf.ToHtml(source, markdown);
markdown.Flush();
return writer.ToString();
}
XmlWriter
and use code similar to above. In general, any calls to WriteString
that are not between calls to WriteStartAttribute
and WriteEndAttribute
should contain the plain text content of the HTML (and therefore, RTF). If you need to perform additional formatting (e.g. separating paragraphs with newlines), you can use the WriteStartElement
and WriteEndElement
to listen for <br>
and <p>
tags. Again the PlainTextWriter
code gives you a decent example (even if perhaps a touch complicated) of what this might look like.
I'm using RtfPipe.Converter.Text.RtfTextConverter to convert rtf to plainText
With latest release Converters are removed. How can convert Rtf to plain text?
Thank you.