Как да конвертирате .ONE файл в PDF в 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. Задайте лиценз с метода SetLicense на Aspose.Note
  4. Заредете входния файл на Microsoft OneNote (.ONE), като използвате Document class
  5. Използвайте опцията за формат SaveFormat.Pdf, за да запазите .ONE файл като PDF
  6. Запазете конвертирания PDF файл, като използвате Save method на обекта Document

Горните стъпки изясняват колко лесно и бързо е конвертирането на файлов формат на OneNote в PDF формат с помощта на Aspose.Tasks за .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.

 Български