Free Support Forum -

Python convert DOCX to PDF using Aspose.Words REST API throws NameError

I am getting an error like this “NameError: name ‘WordsApi’ is not defined”.I am using Python.


Please double check that you have installed the Aspose.Words Cloud SDK for Python package from PIP. It is working fine at my end. Please check the sample working code for reference.

# For complete examples and data files, please go to
# Import module
import asposewordscloud
import asposewordscloud.models.requests
from shutil import copyfile

# Please get your Client ID and Secret from

words_api = asposewordscloud.WordsApi(client_id,client_secret)''

filename = 'C:/Temp/02_pages.docx'
dest_name = 'C:/Temp/02_pages.pdf'
#Convert Docx to PDF
request = asposewordscloud.models.requests.ConvertDocumentRequest(document=open(filename, 'rb'), format='pdf')
result = words_api.convert_document(request)
copyfile(result, dest_name)