Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This Gist contains code snippets related to conversion of Word documents to JPG format using Aspose.Words Cloud SDK for Python
This Gist contains code snippets related to conversion of Word documents to JPG format using Aspose.Words Cloud SDK for Python
# For further samples, please visit https://github.com/aspose-words-cloud/aspose-words-cloud-python
import asposewordscloud
import asposewordscloud.models.requests
from asposewordscloud import ApiClient, WordsApi
from asposewordscloud.rest import ApiException
def main():
try:
# create an instance of WordsApi
words_api = WordsApi("6185429e-17ce-468d-bb81-a51ac9d96c16","73a07e2fb010f559e482d854fe5a8f49")
# Name of input word document
inputFileName = 'source.doc'
resultantFile = 'Converted.jpeg'
# 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, "JPG", 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))
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment