Skip to content

Instantly share code, notes, and snippets.

@blog-aspose-cloud
Last active April 18, 2022 02:29
Show Gist options
  • Save blog-aspose-cloud/49fa604fc135b88003e5b44d593c46c8 to your computer and use it in GitHub Desktop.
Save blog-aspose-cloud/49fa604fc135b88003e5b44d593c46c8 to your computer and use it in GitHub Desktop.
This Gist contains details on how to convert JPG to Word using Aspose.PDF Cloud SDK for Python

Develop JPG to Word Converter using Python SDK


This Gist provides details on how to convert JPG to Word using Aspose.PDF Cloud SDK for Python.

In following code sample, we are going to load multiple JPG images and convert them to Word(DOC) format. Please note that the input JPG images and the resultant word file are stored in Cloud storage. For complete details, please visit Create JPG to Word Converter using Python SDK.

Online JPG to Word Converter

Important Links

Home | Product Page | Docs | API Reference | Cloud Dashboard | Code Samples | Source Code | Blog | Free Support | Free Trial

This Gist contains details on how to convert JPG to Word using Aspose.PDF Cloud SDK for Python
// For complete examples and data files, please go to https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-python
// Get client credentials from https://dashboard.aspose.cloud/
def jpgtoWord():
try:
# Get your ClientId and ClientSecret from https://dashboard.aspose.cloud (free registration required)
client_secret = "1c9379bb7d701c26cc87e741a29987bb"
client_id = "bbf94a2c-6d7e-4020-b4d2-b9809741374e"
#initialize PdfApi client instance using client credetials
pdf_api_client = asposepdfcloud.api_client.ApiClient(client_secret, client_id)
# create PdfApi instance while passing PdfApiClient as argument
pdf_api = PdfApi(pdf_api_client)
# input JPG images available in Cloud storage
imageName = "PDF2JPEG.jpg"
imageName2 = "Client-Credentials.JPG"
# source PDF file to be created during code execution
sourcePDF = "source.pdf"
pageNumber = 1
llx = 10.0
lly = 10.0
urx = 10.0
ury = 10.0
# create a blank PDF file and save in cloud storage
pdf_api.put_create_document(name=sourcePDF)
# inset a JPG image to first page of PDF file and store resultant file in cloud storage
pdf_api.post_insert_image(name=sourcePDF,page_number=pageNumber,llx=llx,lly=lly,urx=urx,ury=ury,image_file_path=imageName)
# Add a new page to the end of document
pdf_api.put_add_new_page(name=sourcePDF)
# Add another JPG image to second page of PDF file
pdf_api.post_insert_image(name=sourcePDF,page_number=2,llx=llx,lly=lly,urx=urx,ury=ury,image_file_path=imageName2)
# Convert JPG to Word and save the output to cloud storage
response = pdf_api.put_pdf_in_storage_to_doc(name=sourcePDF,out_path="Resultant.doc",format="doc",mode="flow")
except ApiException as e:
print("Exception while Convert JPG to DOC using Aspose.PDF Cloud Api: {0}".format(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment