Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This Gist contains details for converting Word document to HTML using Aspose.Words Cloud SDK for Python

This Gist provides details on how we can load MS Word (DOC) and convert to HTML format. The conversion is performed using Aspose.Words Cloud SDK for Python. In following code sample, we are going to load Word document from local drive, upload it to cloud storage and initiate the conversion operation. After the conversion, the resultant HTML is saved on same cloud storage.

Related Blog Post

We recommend visiting the following blog post for detailed information on how to Convert Word to HTML using Python

This Gist contains details for converting Word document to HTML using Aspose.Words Cloud SDK for Python
# For more samples, please visit https://github.com/aspose-words-cloud/aspose-words-cloud-python
# Get App Key and App SID from https://dashboard.aspose.cloud/
try:
# Client credentials
client_secret = "1c9379bb7d701c26cc87e741a29987bb"
client_id = "bbf94a2c-6d7e-4020-b4d2-b9809741374e"
# create an instance of WordsApi
words_api = WordsApi(client_id,client_secret)
# Name of input word document
inputFileName = 'test_multi_pages.docx'
resultantFile = 'Converted.html'
# Upload source Word document to Cloud Storage
words_api.upload_file(asposewordscloud.models.requests.UploadFileRequest(open('C:\\Users\\Downloads\\'+inputFileName, 'rb'), "", None))
# Create an object for Document conversion
request = asposewordscloud.models.requests.GetDocumentWithFormatRequest(inputFileName, "HTML", None, None, None,
None, resultantFile, None)
# initiate Word to JPEG conversion operation
result = words_api.get_document_with_format(request)
# print message in console (optional)
print('Conversion process completed successfully !')
except ApiException as e:
print("Exception while calling WordsApi: {0}".format(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment