这篇简单的文章介绍了如何使用 Python REST API 将 DOCX 转换为 EPUB。Aspose.Words for Python Cloud SDK 可用于将 DOCX 文件导出为 EPUB 文件。如果您想使用 Python Low Code API 创建 Word DOCX 到 EPUB 的转换器,请按照以下步骤操作,并使用示例代码试用该功能。
先决条件
- 创建帐户并获取 API 凭证
- 下载 适用于 Python 的 Aspose.Words Cloud SDK 以执行 DOCX 到 EPUB 的转换
- 使用上述 SDK 设置 Python 项目以将 DOCX 转换为 EPUB
使用 Python Low Code API 将 Word DOC 转换为 EPUB 的步骤
- 设置 API 的客户端 ID 和客户端密钥以将 DOCX 转换为 EPUB
- 使用客户端凭据实例化 WordsAPI 类的对象
- 指定输入 DOCX 和输出 EPUB 文件
- 在文件流中读取输入 DOCX 文件并将其作为参数传递给 ConvertDocumentRequest 类实例
- 调用 转换文档 方法 使用 REST API 将 DOCX 转换为 EPUB
- 将转换后的 EPUB 文件保存在本地磁盘上
上述步骤确保使用 REST API 快速完成 DOCX 到 EPUB 的转换。该过程首先使用 Aspose.Words for Python REST SDK,并通过提供订阅的借用标识符和密钥值来获取 WordsApi 的实例。源 DOCX 文件将使用文件流从磁盘加载,然后使用 ConvertDocument() 方法在云端完成 Word 到 EPUB 的转换,并返回可保存在本地磁盘的 EPUB 文件。
使用 Python REST API 进行 DOC 到 EPUB 转换的代码
此示例代码提供了使用 Python REST API 开发 Word 文档转 EPUB 转换器的基础。您可以选择在转换过程中设置其他参数,例如输出文件名、输出文档路径以及源文件密码。此 DOCX 转 EPUB 功能适用于任何支持此 SDK 的操作系统上的任何无代码或低代码应用程序。
In this topic, we have learned about DOCX to EPUB conversion using Python REST API. If you are interested in rendering BMP for a DOCX file, refer to the article on how to Convert DOCX to BMP with Python REST API.