Printing Documents

Printing a Document

Aspose.Note for Java 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.

1String dataDir = Utils.getSharedDataDir(AlternativeText.class) + "load/";
2		
3Document document = new Document(dataDir + "Aspose.one");
4
5document.print();

Printing Documents 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.

 1String dataDir = Utils.getSharedDataDir(AlternativeText.class) + "load/";
 2
 3Document document = new Document(dataDir + "Aspose.one");
 4
 5//Prints first and second pages using Microsoft XPS Document Writer
 6final DocumentPrintAttributeSet asposeAttr = new DocumentPrintAttributeSet("Microsoft XPS Document Writer");
 7asposeAttr.setPrintRange(1, 2);
 8 
 9//Uncomment line below to retarget output to specified file.
10//This functionality is supported by Microsoft XPS Document Writer.
11//It is not guaranteed that other printers support it.
12//asposeAttr.add(new Destination((new java.io.File("./out.xps")).toURI()));
13  
14document.print(asposeAttr);
 1//Prints 3 copies of first and second pages using virtual pdf printer doPDF 8
 2//It is free and can be downloaded here http://www.dopdf.com/download.php
 3String dataDir = Utils.getSharedDataDir(AlternativeText.class) + "load/";
 4Document doc = new Document(dataDir + "test.one");
 5 
 6 
 7final DocumentPrintAttributeSet asposeAttr = new DocumentPrintAttributeSet("doPDF 8");
 8asposeAttr.setPrintRange(1, 2);
 9asposeAttr.setCopies(3);
10 
11PrintOptions printOptions = new PrintOptions();
12printOptions.setDocumentName("Test.one");
13printOptions.setPrinterSettings(asposeAttr);
14  
15doc.print(printOptions);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.