Nevron Open Vision Documentation
Web Pages (HTML)

NOV rich text view lets you easily import and export documents from and to HTML. You can even load a web page directly in the NOV rich text view, i.e. the NOV text component can act as a mini web browser that includes support for many HTML 5 and CSS 3 features.

Loading from HTML

To import an HTML document from a file, you can use the Load methods as shown in the Loading Documents topic. If you want to load a page directly from an URL, you can use the LoadFromUri method:

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, new NHtmlTextFormat());
}
Saving to HTML

To export a document to HTML, you can use the Save methods as shown the the Saving Documents topic.

Save to HTML
Copy Code
richTextView.SaveToFile(@"C:\HtmlDocument.html");

You can pass an NHtmlSaveSettings instance to the Save method if you want to configure the HTML export process. The NHtmlSaveSettings class exposes the following properties:

The following code snippet demonstrates how to save an HTML document to a file with all CSS styles inlined to style attributes:

Save to HTML with inlined CSS styles
Copy Code
NHtmlSaveSettings saveSettings = new NHtmlSaveSettings();
saveSettings.InlineStyles = true;
richTextView.SaveToFile(@"C:\HtmlDocument.html", new NHtmlTextFormat(), saveSettings);
See Also
Send Feedback