翻譯|行業資訊|編輯:胡濤|2023-11-07 09:43:37.970|閱讀 88 次
概述:在本文中,我們將學習如何在 Java 中將 OneNote 轉換為 HTML,歡迎查閱~
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
OneNote是一種流行的筆記工具,允許用戶以各種格式創建、組織和共享筆記。HTML是一種用于創建網頁的標準標記語言。將 OneNote 轉換為 HTML 的用途有很多,例如在線發布筆記或與不使用 OneNote 的其他人共享它們。在本文中,我們將學習如何在 Java 中將 OneNote 轉換為 HTML。
Aspose.Note是一款處理Microsoft Office OneNote文件的類庫。它允許開發人員在C#、VB.NET、ASP.NET web應用、web服務和Windows應用中中處理.one文件。它能夠打開文件并操作OneNote元素,從文本、圖像和屬性到更多復雜元素,然后到處PNG、GIF、JPEG、BMP或PDF格式。
我們將使用Aspose.Note for Java API 將 OneNote 文檔轉換為 HTML 網頁。它使開發人員能夠創建、讀取、編輯和操作 Microsoft OneNote 文件,而無需安裝 Microsoft Office。Aspose.Note for Java 允許在 Java 應用程序中以編程方式使用 OneNote 筆記本、部分、頁面、節點和其他對象。
請下載API的JAR或將以下pom.xml配置添加到基于Maven的Java應用程序。
<repository> <id>AsposeJavaAPI</id> <name>Aspose Java API</name> <url>//releases.aspose.com/java/repo/</url> </repository>
<dependency> <groupId>com.aspose</groupId> <artifactId>aspose-note</artifactId> <version>23.7</version> <classifier>jdk17</classifier> </dependency>
我們可以創建一個 OneNote 文檔,并按照以下步驟以編程方式將其轉換為 HTML 網頁:
以下代碼示例演示如何使用 Java 創建 OneNote 文檔并將其轉換為 HTML。
// This code example demontstrates how to create a new OneNote document and convert it to HTML. // create an object of the Document class Document doc = new Document(); // Add a new Page Page page = new Page(); // Specify TextStyle and set formatting properties ParagraphStyle titleTextStyle = new ParagraphStyle() .setFontColor(Color.black) .setFontName("Arial") .setFontSize(20); // Specify title text RichText titleText = new RichText().append("This is a Title!"); titleText.setParagraphStyle(titleTextStyle); // Initialize Title Title title = new Title(); title.setTitleText(titleText); // Set page title page.setTitle(title); // Add Page node doc.appendChildLast(page); // Save OneNote document as HTML doc.save("C:\\Files\\CreateOneNoteDocAndSaveToHTML_out.html", SaveFormat.Html);
我們還可以按照以下步驟將任何現有 OneNote 文檔轉換為 HTML 網頁:
以下代碼示例演示如何使用 Java 將現有 OneNote 文檔轉換為 HTML。
// This code example demontstrates how to convert an existing OneNote document to HTML. // Initialize OneNote document Document doc = new Document("C:\\Files\\Sample1.one"); // Save as HTML String dataDir = "C:\\Files\\Sample1_out.html"; doc.save(dataDir, SaveFormat.Html);
我們可以按照以下步驟將一系列特定頁面從 OneNote 文檔轉換為 HTML 網頁:
以下代碼示例演示如何使用 Java 將一系列頁面從 OneNote 文檔導出為 HTML。
// This code example demonstrates how to convert a range of pages from OneNote document to HTML. // Initialize OneNote document Document doc = new Document("C:\\Files\\Sample1.one"); // Define HTML save options HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions(); htmlSaveOptions.setPageCount(1); htmlSaveOptions.setPageIndex(0); // Save into HTML format String dataDir = "C:\\Files\\ConvertRange.html"; doc.save(dataDir, htmlSaveOptions);
我們可以按照以下步驟將 OneNote 文檔轉換為 HTML 網頁并內嵌所有資源(如字體、圖像和 CSS):
以下代碼示例演示如何通過使用 Java 嵌入所有資源來將 OneNote 文檔轉換為 HTML。
// This code example demonstrates how to convert a OneNote document to HTML and embed resources. // Initialize OneNote document Document doc = new Document("C:\\Files\\Sample1.one"); // Define HTML save options HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions(); htmlSaveOptions.setExportCss(ResourceExportType.ExportEmbedded); htmlSaveOptions.setExportFonts(ResourceExportType.ExportEmbedded); htmlSaveOptions.setExportImages(ResourceExportType.ExportEmbedded); htmlSaveOptions.setFontFaceTypes(FontFaceType.Ttf); // Save into HTML format String dataDir = "C:\\Files\\ConvertWithEmbeddedResources.html"; doc.save(dataDir, htmlSaveOptions);
您還可以嘗試使用上述 API 開發的免費在線
在本文中,我們學習了如何使用 Java 將 OneNote 文檔轉換為 HTML 網頁。通過利用 Aspose.Note for Java,我們發現了一種簡單有效的方法將 OneNote 轉換為 HTML,只需要幾行代碼。通過執行本文中概述的步驟,您可以輕松地使用 Java 創建 OneNote 到 HTML 轉換器應用程序。
歡迎下載|體驗更多Aspose產品
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn