How to Convert .ONE File to PDF in C#

This how-to topic elaborates how to convert .ONE file to PDF in C#. OneNote to PDF conversion in C# is easy using Aspose.Note and doesn’t require you to have Microsoft OneNote installed. The OneNote files converted to PDF are easy to read, review, and share later on in a format which is easy to use on any platform or device.

Steps to Convert .ONE File to PDF in C#

  1. Install Aspose.Note for .NET package from NuGet.org
  2. Use Aspose.Note, Aspose.Note.Saving, and Aspose.Note.Saving.Pdf namespaces
  3. Set license with SetLicense method of Aspose.Note
  4. Load input Microsoft OneNote (.ONE) file using Document class
  5. Use SaveFormat.Pdf format option to save .ONE file as PDF
  6. Save the converted PDF file using Save method of Document object

The above steps clarify how easy and quick it is to convert a OneNote file format to a PDF format using Aspose.Tasks for .NET API.

Code to Convert .ONE File to PDF in C#

using System;
//Add reference to Aspose.Note for .NET API
//Use following namespaces to convert OneNote (.One) file to PDF
using Aspose.Note;
using Aspose.Note.Saving;
using Aspose.Note.Saving.Pdf;
namespace ConvertOneNoteFileToPDF
{
class Program
{
static void Main(string[] args)
{
//Set Aspose license before converting OneNote (.one) file to PDF
//using Aspose.Note for .NET
Aspose.Note.License AsposeNoteLicense = new Aspose.Note.License();
AsposeNoteLicense.SetLicense(@"c:\asposelicense\license.lic");
//create an instance of Document object and load input .one file to convert
Document OneNoteDocument = new Document("InputOneNoteDocument.one");
//save the .One file to PDF using Save method and Pdf SaveFormat
OneNoteDocument.Save("OneNoteConvertedToPDF.pdf",SaveFormat.Pdf);
}
}
}

This C# code sample shows how you can convert .ONE file to PDF in a few lines of code. You’re not required to install Microsoft OneNote on the computer or server where you want to run this code.

 English