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:
- C# API to Convert PDF to OneNote
- Convert PDF to OneNote
- Convert Multiple PDF Files to OneNote
- Insert PDF into OneNote on One Page
- 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:
- Create an instance of the Document class.
- Call the Import() method with the PDF file path.
- 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 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:
- Create an instance of the Document class.
- Call the Import() method with the PDF file path.
- Repeat the above step to import more PDF files.
- 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:
- Firstly, create an instance of the Document class.
- Next, create an instance of the PdfImportOptions class.
- Then, initialize the MergeOptions class object.
- Next, set the ImportAsSinglePage as true and PageSpacing properties.
- Then, call the Import() method with the PDF file path.
- After that. repeat the above step to import more PDF files.
- 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:
- Firstly, create an instance of the Document class.
- Next, initialize the MergeOptions class object.
- Then, set the ImportAsSinglePage as true and PageSpacing properties.
- Next, get a collection of pages from PDF using the PdfImporter.Import() method. It takes a PDF file path as an argument.
- After that, call the Merge() method to merge the specified number of pages.
- 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.