通過 Java 轉換 Microsoft OneNote

將 Microsoft OneNote 轉換為 PDF 和圖像,包括 BMP、JPG、PNG、TIFF,以構建跨平台的 Java 應用程序。

 

Aspose.Note for Java 是一個功能豐富的 OneNote API,它使 Java 應用程序能夠與 OneNote 文檔動態交互,而無需任何其他軟件。 API 使開發人員能夠創建、讀取、操作和導出 Microsoft OneNote 文件格式的內容。該 API 還允許管理附件、文本、超鏈接、表格、標籤和文本樣式。

OneNote API 易於使用、節省時間,並且開發人員可以用更少的代碼創建強大的解決方案。最重要的是,它是一個獨立的組件,不需要任何其他工具或軟件即可處理 OneNote 文件。每當需要在您的組織定制軟件中操作 Microsoft OneNote 文件時,OneNote API 可以通過增強您的應用程序功能來幫助實現這一點。它是一個獨立的 API,無需安裝 Microsoft OneNote 或任何其他軟件。程序員可以輕鬆地集成它以將 .one 擴展文件轉換為所需的格式,如 BMP、GIF、JPEG、PNG 或 TIFF 圖像格式或 PDF 文件。

將 OneNote 轉換為 JPG、PNG、BMP、TIFF 圖像

使用 OneNote API,開發人員可以輕鬆地將 Microsoft® OneNote one / onetoc2 轉換為圖像格式。轉換過程是,使用 文檔類 加載 Note 文件。使用 SaveFormat.Imageformat 創建 ImageSaveOptions 對像以用作 [SaveFormat] 中的參數( https://reference.aspose.com/note/java/com.aspose.note/document/#save-java.lang.String-SaveOptions- ).除了桌面軟件解決方案,它很容易集成到基於網絡的應用程序中,用於基於瀏覽器的圖像轉換解決方案。

Java Code for Microsoft OneNote to Image Files Conversion

1. // Path of document directory.
2. String dirPath = Utils.getSharedDataDir(SaveOneNoteDocToStream.class) + "load/";
3. 
4. // Load the file into Aspose.Note using Document class.
5. Document oneFile = new Document(dirPath + "sourceFile.one");
6. 
7. // Images conversion options
8. ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Jpeg);
9. 
10. String outputFile = dirPath + "oneToImage.jpeg";
11. 
12. // Save the document.
13. oneFile.save(outputFile, options);
 

OneNote 到 PDF 轉換

至於圖片轉換,OneNote one 和onetoc2 轉PDF 的過程幾乎是一樣的。使用 文檔類 ,加載OneNote文件。加載文檔後,以outout PDF文件和 SaveFormat .Pdf為參數調用保存方法。轉換時間因文件而異,具體取決於文檔大小。

Java Code to Convert OneNote to PDF

1. // The path to the documents directory.
2. String dirPath = Utils.getSharedDataDir(SaveOneNoteDocToStream.class) + "load/";
3. 
4. // Load the document into Aspose.Note.
5. Document oneFile = new Document(dirPath + "sourceFile.one");
6. 
7. dirPath = dirPath + "oneFiletoPdf_out.pdf";
8. 
9. // Save the document.
10. oneFile.save(dirPath, new PdfSaveOptions());