Word and PDF documents do not have good user experience and readability on e-reader. You need to convert these documents to eBook format e.g. EPUB or MOBI. Aspose.Words Cloud supports conversion of Word document to EPUB.
It can convert the industry standard file formats to the EPUB format. The resultant EPUB document adheres the EPUB standards. The content, formatting, images, hyperlinks, metadata and navigation of the source document is preserved in resultant EPUB documents.
In this article, I will show you how easily you can convert a Microsoft Word document to EPUB using the Python SDK. If you are using some other programming language, then you can check SDK of your choice from our GitHub repository. It contains the complete source code of the SDK along with the working examples.
I am converting Word document to EPUB with standard options. However, you can set a lot of parameters to control the out a document using the EpubSaveOptions request parameter. Here we go:
• Install Python package
• Upload source document to Storage
• Convert document to EPUB
Install Python package
Install aspose-words-cloud with PIP from PyPI by:
pip install aspose-words-cloud
Code:
import asposewordscloud import asposewordscloud.models.requests api_client = asposewordscloud.ApiClient() # Get App key and App SID from https://cloud.aspose.com api_client.configuration.host = 'https://api.aspose.cloud' api_client.configuration.api_key['api_key'] = 'xxxxxxxxxxxxxxxxxxxxxxxxx' # Put your appKey here api_client.configuration.api_key['app_sid'] = 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx' # Put your appSid here words_api = asposewordscloud.WordsApi(api_client) filename = 'TestFile.docx' remote_name = 'TestPostDocumentSaveAs.docx' dest_name = 'TestPostDocumentSaveAs.epub' #upload DOCX file to storage request_upload = asposewordscloud.models.requests.UploadFileRequest(filename,remote_name) response_upload = words_api.upload_file(request_upload) #Convert DOCX to EPUB and save to storage save_options = asposewordscloud.SaveOptionsData(save_format='epub', file_name=dest_name) request_conversion = asposewordscloud.models.requests.SaveAsRequest(remote_name, save_options) response_conversion = words_api.save_as(request_conversion) print(response_conversion)
Top comments (0)