VB icon

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

Email
Submitted on: 7/29/2015 11:08:59 AM
By: Sherazam  
Level: Intermediate
User Rating: Unrated
Compatibility: C#, VB.NET
Views: 3659
 
     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.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: How to Create OneNote File and Convert it into HTML Format inside .NET Apps
// Description: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.
// By: Sherazam
//**************************************

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.
// Creating a OneNote and Saving into HTML using the Default Options
// [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
})
<p><strong>Overview: Aspose.Note for .NET</strong></p>
Aspose.Note for .NET is a set of .NET components that enables developers to work with Microsoft Office OneNote files in C#, VB.NET, ASP.NET web applications, web services & Windows applications. It allows developers to open files & manipulate elements of OneNote books, from text, images & properties, to more complex elements, & then export to PNG, GIF, JPEG, BMP or PDF formats. It is a pure .NET alternative to the MS OneNote Object Model & supports OneNote 2010, OneNoteĀ® 2010 SP1 & 2013 files.
<ul>
 <li> Homepage of <a href="http://www.aspose.com/.net/note-component.aspx"><strong>Aspose.Note for .NET</strong></a></li>
 <li><a href="http://www.aspose.com/community/files/51/.net-components/aspose.note-for-.net/default.aspx"><strong>Download</strong></a> Aspose.Note for .NET</li>
</ul>


Other 44 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.