ODT to Word

Convert ODT to Word using Python SDK

This article is a continuation of our earlier post Convert ODT to DOC using Java REST API and we are going to discuss the details on how to convert ODT to Word using Python SDK. The reason we are converting open document format to MS Word format is because of its wide acceptance and adaptability among users. Many applications use this format as a defacto standard and are commonly used in Universities, Institutes, Government Organizations, etc.

DOC Conversion API

In order to convert ODT to Word in Python application, we need to use Aspose.Words Cloud SDK for Python. It is capable of editing, manipulating, and converting Word documents to various supported formats. Now please execute the following command to install the SDK:

pip install aspose-words-cloud

Another important step is the creation of a free account by visiting Aspose.Cloud dashboard. It enables us to access the Cloud APIs as well as manage documents in cloud storage.

ODT to Word in Python

Please follow the instructions given below to convert ODT to Word using a Python code snippet.

  • First, create an object of WordsApi while passing client details as arguments
  • Secondly, upload the input ODT file to cloud storage using the upload_file(…) method
  • Now create an instance of GetDocumentWithFormatRequest(…) which takes input ODT file name, resultant file format, and output file names are arguments
  • Finally, call get_document_with_format(…) method which takes GetDocumentWithFormatRequest object as argument.
  • The resultant Word document (DOCX) is saved in cloud storage
ODT to Word

Image:1- ODT to Word conversion preview

Convert ODT to DOCX using cURL Commands

We can also convert ODT to DOCX format using the cURL Commands. All we need to do is first generate a JWT token based on client credentials.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now that we have the JWT token, we need to execute the following command to save ODT to DOCX format.

curl -v -X GET "https://api.aspose.cloud/v4.0/words/TableDocument.odt?format=DOCX&outPath=resultant.docx" \
-H  "accept: application/octet-stream" \
-H  "Authorization: Bearer <JWT Token>"

Conclusion

We have learned the details on how we can programmatically convert ODT to DOCX using Python code snippets as well as through cURL commands. Apart from this conversion, you can also perform a plethora of functions as mentioned in Developers Guide. In case you face any issues while using the API, please feel free to contact us via the technical support forum.