Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 23, 2021 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/bb076338de32dba29b0a50e9a6b64b17 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/bb076338de32dba29b0a50e9a6b64b17 to your computer and use it in GitHub Desktop.
Print OneNote .one file Programmatically using Java
// Load input OneNote file with the Document class.
Document document = new Document("Aspose.one");
// Print first and second pages using Microsoft XPS Document Writer
final DocumentPrintAttributeSet asposeAttr = new DocumentPrintAttributeSet("Microsoft XPS Document Writer");
asposeAttr.setPrintRange(1, 2);
// Print the OneNote file
document.print(asposeAttr);
//Prints 3 copies of first and second pages using virtual pdf printer doPDF 8
//It is free and can be downloaded here http://www.dopdf.com/download.php
// Load input OneNote file
Document doc = new Document("test.one");
// Specify the virtual printer and properties
final DocumentPrintAttributeSet asposeAttr = new DocumentPrintAttributeSet("doPDF 8");
asposeAttr.setPrintRange(1, 2);
asposeAttr.setCopies(3);
// Set printer settings with PrintOptions
PrintOptions printOptions = new PrintOptions();
printOptions.setDocumentName("Test.one");
printOptions.setPrinterSettings(asposeAttr);
// Print the OneNote file to virtual printer
doc.print(printOptions);
// Load input OneNote file with the Document constructor.
Document document = new Document("Aspose.one");
// Print the OneNote document.
document.print();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment