Print OneNote Documents using C# API
Contents
[
Hide
Show
]Printing a Document
Aspose.Note for .NET API lets you print OneNote documents to the printer. The Print method exposed by Document class lets you print the loaded document to the printer.
1// The path to the documents directory.
2string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
3
4var document = new Aspose.Note.Document(dataDir + "Aspose.one");
5
6document.Print();
Printing Document with Print Options
You can also print a document to Printer with specified print options using the PrintOptions class. The PrinterSettings class can be used to specify additional printer settings such as page layout and margins.
1// The path to the documents directory.
2string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
3
4var document = new Aspose.Note.Document(dataDir + "Aspose.one");
5
6var printerSettings = new PrinterSettings() { FromPage = 0, ToPage = 10 };
7printerSettings.DefaultPageSettings.Landscape = true;
8printerSettings.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(50, 50, 150, 50);
9
10document.Print(new PrintOptions()
11{
12 PrinterSettings = printerSettings,
13 Resolution = 1200,
14 PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(),
15 DocumentName = "Test.one"
16});