0

while trying to convert HTML to RTF through Below Code

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();

here Document.Write(html); and Document.ExecCommand getting error here Which using required to overcome this am new to this Please guide us

example: using System.Windows.Controls;

here is full code image full

indralove
  • 1
  • 2
  • _"getting error here"_ - read [ask] and show the actual error, as wel as what you've tried. – CodeCaster Dec 09 '21 at 16:48
  • here is full code https://i.stack.imgur.com/Is7MW.png – indralove Dec 09 '21 at 16:49
  • Why don't you just right click (or `Ctrl+.`) on the errors, select _Quick actions and refactoring_ and add the using statement it suggests? – The2Step Dec 09 '21 at 16:52
  • sir @CodeCaster showing error like : CS1061 'object' does not contain a definition for 'Write' and no accessible extension method 'Write' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) – indralove Dec 09 '21 at 16:57
  • there is now own WebBrowser class – indralove Dec 09 '21 at 17:00

1 Answers1

0

You're using the WPF WebBrowser control.

Instead of System.Windows.Controls use WinForms: using System.Windows.Forms;

Or see How can I get an HtmlElementCollection from a WPF WebBrowser and How to get HTML from WebBrowser control, cast WebBrowser.Document to the appropriate type, or host the control in your WPF window.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272