翻譯|使用教程|編輯:胡濤|2022-07-05 14:14:53.463|閱讀 195 次
概述:在本文中,我們將向您展示如何使用 Java 以編程方式將 MS Word 文件轉換為 EPUB。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
大多數智能設備,如智能手機、平板電腦、筆記本電腦等,都支持EPUB格式來查看或閱讀文檔。它是電子書或電子出版物的常用格式。另一方面,MS Word 格式,如DOCX、DOC等,是數字世界中廣泛使用的文檔格式之一。在本文中,我們將向您展示如何使用 Java 以編程方式將 MS Word 文件轉換為 EPUB。此外,您將學習如何使用不同的選項自定義 Word 到 EPUB 的轉換。
Aspose.Words for . Python 最新下載
為了將 DOCX、DOC 等文件轉換為 EPUB 格式,我們將使用Aspose.Words for Java。上述 API 允許您無縫地創建和操作 MS Word 文檔。此外,您可以將 Word 文件高保真轉換為其他格式,例如 EPUB、HTML、PDF 等。您可以下載API 的 JAR 文件或使用以下配置將其安裝到基于 Maven 的應用程序中。
<repository> <id>AsposeJavaAPI</id> <name>Aspose Java API</name> <url>//repository.aspose.com/repo/</url> </repository> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-words</artifactId> <version>21.11</version> <type>pom</type> </dependency>
以下是在 Java 中將 Word DOCX 文件轉換為 EPUB 的步驟。
以下代碼示例展示了如何在 Java 中將 DOCX 文件轉換為 EPUB。
// Load the Word document Document doc = new Document("document.docx"); // Convert Word document to EPUB doc.save("word-to-epub.epub");
您還可以使用不同的選項修改 API 在 Word 到 EPUB 轉換中的默認行為。例如,您可以指定編碼方案、導出文檔信息、設置拆分條件等。以下是自定義 Word 到 EPUB 轉換的步驟。
以下代碼示例顯示了如何自定義 Word 到 EPUB 的轉換。
// Load the Word document Document doc = new Document("document.docx"); // Create an object for save options HtmlSaveOptions saveOptions = new HtmlSaveOptions(); // Set the desired encoding saveOptions.setEncoding(Charset.forName("UTF-8")); // Specify at what elements to split the internal HTML at. This creates a new HTML within the EPUB // which allows you to limit the size of each HTML part. This is useful for readers which cannot read // HTML files greater than a certain size e.g 300kb. saveOptions.setDocumentSplitCriteria(DocumentSplitCriteria.HEADING_PARAGRAPH); // Enable export of document properties saveOptions.setExportDocumentProperties(true); // Specify save format saveOptions.setSaveFormat(SaveFormat.EPUB); // Convert Word document to EPUB doc.save("word-to-epub.epub", saveOptions);
在本文中,您學習了如何在 Java 中將 Word 文檔轉換為 EPUB 格式。此外,您還了解了如何使用不同的選項修改 Word 到 EPUB 的轉換。此外,您還可以訪問文檔以了解 Aspose.Words for Java 提供的其他內容。此外,您可以通過在線客服聯系我們!
歡迎下載|體驗更多Aspose產品
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn