How to Create OneNote File and Convert it into HTML Format inside .NET Apps

This Technical tip explains how .NET developers can create and convert OneNote to HTML Format inside their .NET applications. Aspose.Note supports creating OneNote file and then saving it into html file format. To use this feature, import the Aspose.Note.Saving namespace into your application project. It has numerous valuable classes for rendering, for example HtmlSaveOptions, ImageSaveOptions, PdfSaveOptions, and SaveOptions. Aspose.Note for .NET offers the Document class that represents a OneNote file. The Document class exposes the Save method that can be called to convert the OneNote file into the HTML file format. The HtmlSaveOptions class provides options for creating HTML file, such as PageIndex, PageCount, SaveFormat and others.
//your code here...// [C# Code Sample] // Initialize OneNote document Document doc = new Document(); Aspose.Note.Page page = new Aspose.Note.Page(doc); // default style for all text in the document. TextStyle textStyle = new TextStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 }; page.Title = new Title(doc) { TitleText = new RichText(doc) { Text = "Title text.", DefaultStyle = textStyle }, TitleDate = new RichText(doc) { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), DefaultStyle = textStyle }, TitleTime = new RichText(doc) { Text = "12:34", DefaultStyle = textStyle } }; doc.AppendChild(page); // save as HTML format doc.Save("out.html"); //[VB.NET Code Sample] ' Initialize OneNote document Dim doc As New Aspose.Note.Document() Dim page As New Aspose.Note.Page(doc) ' default style for all text in the document. Dim textStyle As New TextStyle() With {.FontColor = System.Drawing.Color.Black, .FontName = "Arial", .FontSize = 10} page.Title = New Title(doc) With { .TitleText = New RichText(doc) With {.Text = "Title text.", .DefaultStyle = textStyle}, .TitleDate = New RichText(doc) With {.Text = New DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), .DefaultStyle = textStyle}, .TitleTime = New RichText(doc) With {.Text = "12:34", .DefaultStyle = textStyle} } doc.AppendChild(page) ' save as HTML format doc.Save("out.html") // Creating a OneNote and Saving a Page Range into HTML //The following example shows how to create a OneNote and save a page range into HTML using the HtmlSaveOptions class. It sets the PageCount and PageIndex properties. //[C# Code Sample] // Initialize OneNote document Document doc = new Document(); Aspose.Note.Page page = new Aspose.Note.Page(doc); //default style for all text in the document. TextStyle textStyle = new TextStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 }; page.Title = new Title(doc) { TitleText = new RichText(doc) { Text = "Title text.", DefaultStyle = textStyle }, TitleDate = new RichText(doc) { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), DefaultStyle = textStyle }, TitleTime = new RichText(doc) { Text = "12:34", DefaultStyle = textStyle } }; doc.AppendChild(page); // save as HTML format doc.Save("out.html", new HtmlSaveOptions { PageCount = 1, PageIndex = 0 }); //[VB.NET Code Sample] ' Initialize OneNote document Dim doc As New Aspose.Note.Document() Dim page As New Aspose.Note.Page(doc) 'default style for all text in the document. Dim textStyle As New TextStyle() With { .FontColor = System.Drawing.Color.Black, .FontName = "Arial", .FontSize = 10 } page.Title = New Title(doc) With { .TitleText = New RichText(doc) With {.Text = "Title text.", .DefaultStyle = textStyle}, .TitleDate = New RichText(doc) With {.Text = New DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), .DefaultStyle = textStyle}, .TitleTime = New RichText(doc) With {.Text = "12:34", .DefaultStyle = textStyle} } doc.AppendChild(page) ' save as HTML format doc.Save("out.html", New Aspose.Note.Saving.HtmlSaveOptions() With { .PageCount = 1, .PageIndex = 0 })

Url: http://www.aspose.com/.net/note-component.aspx

Language: C# | User: Sheraz Khan | Created: Jul 29, 2015 | Tags: Create OneNote document .NET export OneNote file into HTML Saving OneNote into HTML using Default Options Initialize OneNote document .NET OneNote API Save OneNote Pages Range into HTML