Basic samples how to convert OneNote to PDF

PDF documents are widely used as a standard format of exchanging documents between organizations, government sectors and individuals. It’s a popular format so developers are often asked to convert Microsoft OneNote documents to PDF documents. For this purpose, Aspose.Note for .NET supports converting OneNote to PDF documents without using any other component.

Save OneNote to PDF using default options

The following code example demonstrates how to convert OneNote to PDF using the default options. With default options all pages of the document are saved and present images are compressed by auto selected algorithm.

1// The path to the documents directory.
2string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
3
4// Load the document into Aspose.Note.
5Document oneFile = new Document(dataDir + "Aspose.one");
6
7dataDir = dataDir + "SaveWithDefaultSettings_out.pdf";
8// Save OneNote to PDF
9oneFile.Save(dataDir, SaveFormat.Pdf);

Save specified page’s range of OneNote to PDF

The following code example demonstrates how to convert a specified range of pages from OneNote to PDF. This range is specified by setting PageIndex and PageCount properties.

The code below saves the first page of OneNote document into a file in PDF format.

 1// The path to the documents directory.
 2string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
 3
 4// Load the document into Aspose.Note.
 5Document oneFile = new Document(dataDir + "Aspose.one");
 6
 7// Initialize PdfSaveOptions object
 8PdfSaveOptions opts = new PdfSaveOptions();
 9
10// Set page index: 0 means to start saving from first page.
11opts.PageIndex = 0;
12
13// Set page count: 1 means to save only one page.
14opts.PageCount = 1;
15
16dataDir = dataDir + "SaveRangeOfPagesAsPDF_out.pdf";
17
18// Save OneNote to PDF
19oneFile.Save(dataDir, opts);

Save OneNote to PDF using Jpeg compession for images

The following code example demonstrates how to convert OneNote to PDF with compressing of all images using JPEG.

 1// The path to the documents directory.
 2string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
 3
 4// Load the document into Aspose.Note.
 5Document oneFile = new Document(dataDir + "Aspose.one");
 6
 7// Initialize PdfSaveOptions object
 8PdfSaveOptions opts = new PdfSaveOptions
 9                      {
10                         // Use Jpeg compression
11                         ImageCompression = Saving.Pdf.PdfImageCompression.Jpeg,
12                                         
13                         // Quality for JPEG compression
14                         JpegQuality = 90
15                      };
16
17dataDir = dataDir + "sample.pdf";
18
19// Save OneNote to PDF
20oneFile.Save(dataDir, opts);

Save OneNote to PDF without page breaks

The following code example demonstrates how to convert OneNote to PDF without page breaks of pages with too long content.

 1// The path to the documents directory.
 2string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
 3
 4// Load the document into Aspose.Note.
 5Document oneFile = new Document(dataDir + "OneNote.one");
 6
 7var dst = Path.Combine(dataDir, "SaveToPdfUsingA4PageSettingsWithoutHeightLimit.pdf");
 8
 9// Save the document.
10oneFile.Save(dst, new PdfSaveOptions() { PageSettings = PageSettings.A4NoHeightLimit });
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.