0

I was using System.Windows.Forms.RichTextBox to convert rtf text to plain text. However, I would like to migrate to .NET Standard, which does not have this. Is there some proper way to do it without depending on Windows Forms?

I would assume, there should be some common library like System.Text.Rtf, but apparently it is not. :)

private static string RtfToPlainText(string rtf)
{
  var textBox = new System.Windows.Forms.RichTextBox
  {
     Rtf = rtf
  };

  return textBox.Text;
}
Thorberg
  • 93
  • 6
  • @Enigmativity I don't know what you voted, but this is not an off-site resource request. – CodeCaster Nov 10 '21 at 09:36
  • `System.Windows.Forms.RichTextBox` uses native calls to the OS to return the text. It makes sense that it's not in .NET Standard. – Enigmativity Nov 10 '21 at 09:36
  • @CodeCaster - It seemed like the OP is asking for a library. – Enigmativity Nov 10 '21 at 09:37
  • 1
    @Enigmativity yes, but. Everything we do requires libraries, if you don't want to reinvent the RTF parsing wheel. They're asking how to do this, not asking "which is the best library to do so". Pedantic but important distinction. – CodeCaster Nov 10 '21 at 09:38

0 Answers0