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#
- Install Aspose.Note for .NET package from NuGet.org
- Use Aspose.Note, Aspose.Note.Saving, and Aspose.Note.Saving.Pdf namespaces
- Set license with SetLicense method of Aspose.Note
- Load input Microsoft OneNote (.ONE) file using Document class
- Use SaveFormat.Pdf format option to save .ONE file as PDF
- 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.