To import an HTML document from a file, you can use the Load methods as shown in the Loading Documents topic.
Load HTML from local file |
Copy Code
|
---|---|
richTextView.LoadFromLocalFile(@"C:\MyDocument.html");
|
If you want to load a page directly from an URL, you can use the LoadFromUri method. Note that loading a web page requires browser-like capabilities like full support for CSS and JavaScript and while the NOV rich text view comoes with good CSS support, it doesn't support JavaScript, so some pages might not load correctly.
Load a web page from an URL |
Copy Code
|
---|---|
richTextView.LoadFromUri(new NUri("https://en.wikipedia.org/wiki/EPUB")); |
If you want to be notified when the web page has loaded, you should subscribe to the DocumentLoaded event.
You can also load an HTML document from a string if you convert that string to a byte array first and place it in a memory stream as the following code snippet demonstrates:
Load HTML from string |
Copy Code
|
---|---|
string html = "<p>This is a paragraph with <b>some bold text</b> and <span style='color:red'>some red text</span>.</p>"; using (MemoryStream stream = new MemoryStream(NEncoding.UTF8.GetBytes(html))) { richTextView.LoadFromStream(stream, NTextFormat.Html); } |