Convert PDF to OneNote using C#

PDF allows sharing and printing of documents without losing the formatting which makes it the most popular format. In certain cases, we may need to import the content of PDF documents into the OneNote document. OneNote allows collecting, organizing, and collaborating free form information and multi-user collaboration in the form of notes, drawings, screen clippings, and audio commentaries. In this article, we will learn how to convert a PDF to OneNote in C#.

The following topics shall be covered in this article:

  1. C# API to Convert PDF to OneNote
  2. Convert PDF to OneNote
  3. Convert Multiple PDF Files to OneNote
  4. Insert PDF into OneNote on One Page
  5. Convert PDF to OneNote and Merge Pages

C# API to Convert PDF to OneNote

To convert a PDF document to OneNote, we will be using the Aspose.Note for .NET API. It allows creating, reading, and converting OneNote documents programmatically without using Microsoft OneNote. It also allows importing content from PDF documents into OneNote documents.

The Document class of the API represents a OneNote document. The Import() method of this class imports a set of pages from the provided PDF document. The Save() method saves the OneNote document to a file. We can merge a set of pages into the document using the Merge() method. The PdfImporter class of the API enables us to import content from documents in PDF format. You may also read more about classes and methods in the API references.

Please either download the DLL of the API or install it using NuGet.

PM> Install-Package Aspose.Note

Convert PDF to OneNote using C#

We can easily convert any PDF document into a OneNote document by following the steps given below:

  1. Create an instance of the Document class.
  2. Call the Import() method with the PDF file path.
  3. Finally, save as OneNote using the Save() method.

The following code sample shows how to convert a PDF to a OneNote document using C#.

Convert PDF to OneNote using C#

Convert PDF to OneNote using C#.

Convert Multiple PDF Files to OneNote using C#

We can also import or convert multiple PDF files into a single OneNote document by following the steps given below:

  1. Create an instance of the Document class.
  2. Call the Import() method with the PDF file path.
  3. Repeat the above step to import more PDF files.
  4. Finally, save as OneNote using the Save() method.

The following code sample shows how to convert Multiple PDF files to a OneNote document using C#.

Insert PDF into OneNote on One Page using C#

We can import a PDF document into OneNote as one page by following the steps given below:

  1. Firstly, create an instance of the Document class.
  2. Next, create an instance of the PdfImportOptions class.
  3. Then, initialize the MergeOptions class object.
  4. Next, set the ImportAsSinglePage as true and PageSpacing properties.
  5. Then, call the Import() method with the PDF file path.
  6. After that. repeat the above step to import more PDF files.
  7. Finally, save as OneNote using the Save() method.

The following code sample shows how to insert every PDF document to a single OneNote page using C#.

Convert PDF to OneNote and Merge Pages in C#

We can import all the pages from a PDF document and merge the selected pages in OneNote by following the steps given below:

  1. Firstly, create an instance of the Document class.
  2. Next, initialize the MergeOptions class object.
  3. Then, set the ImportAsSinglePage as true and PageSpacing properties.
  4. Next, get a collection of pages from PDF using the PdfImporter.Import() method. It takes a PDF file path as an argument.
  5. After that, call the Merge() method to merge the specified number of pages.
  6. Finally, save as OneNote using the Save() method.

The following code sample shows how to import all pages from PDF grouping 5 pages into a single OneNote page using C#.

Get a Free License

You can get a free temporary license to try the library without evaluation limitations.

Conclusion

In this article, we have learned how to:

  • create a new OneNote document using C#;
  • save PDF as a OneNote;
  • import single or multiple PDF documents into OneNote;
  • save the OneNote document programmatically;

Besides, you can learn more about Aspose.Note for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on our forum.

See Also