Convert PDF to HTML with Python using Aspose.PDF REST API throws 403 exception

i am using below coding and getting 403 expection. Attached pdf is my input. Please advice.

i am using apikey , appSid what i received in aspose total product.

import asposepdfcloud
from asposepdfcloud.PdfApi import PdfApi
from asposepdfcloud.PdfApi import ApiException
#from asposepdfcloud.models import AppendDocument

import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
#from asposestoragecloud.StorageApi import ResponseMessage

#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Pdf API SDK
api_client = asposepdfcloud.ApiClient.ApiClient(apiKey, appSid, True)
pdfApi = PdfApi(api_client);

#set input file name
fileName = "Telangana Cotton Mills, L.P.- Draft K1 Sample - Readable"
name = fileName + “.pdf”
#format = "tiff"

try:
format = “html”;
print “before call”
#invoke Aspose.Pdf Cloud SDK API to convert PDF to DOC
response = pdfApi.GetDocumentWithFormat(name, format)
print “After call”
print response
if response.Status == “OK”:
#save converted format file from response
outfilename = “c:/temp/” + fileName + “.” + “.zip”
with open(outfilename, ‘wb’) as f:
for chunk in response.InputStream:
f.write(chunk)


except ApiException as ex:
print “ApiException:” + ex.message
print “Code:” + str(ex.code)
print “Message:” + ex.message

Dear support team,


Please let me know when i shall get the feedback.

Hi Bharani,

We are sorry for the delayed response. Please note 403 error arises while some resource is missing. Please check complete code for PDF to HTML conversion using Aspose.Pdf for Cloud and double check the availability of source file as well. If the issue persist then please share your source PDF document and share your credentials(AppSID/AppKey) via private message. We will look into the issue and will guide you accordingly.

Best Regards,

Hi Bharani,

Thanks for sharing required details via email. I am looking into it and will update you my findings soon. However meanwhile I will appreciate it if you please amend your code as following and share the results, as your code shows that you are not uploading source document to storage for processing.

#set input file name

fileName = "Telangana Cotton Mills, L.P.- Draft K1 Sample - Readable"

name = fileName + ".pdf"

format = "html"

storage = ""

folder = ""

outPath = ""


try:



print "before call"

#upload file to aspose cloud storage

response = storageApi.PutCreate(name, data_folder + name)

#invoke Aspose.Pdf Cloud SDK API to convert PDF to DOC

response = pdfApi.GetDocumentWithFormat(name, format, storage, folder, outPath)

print "After call"

print response

if response.Status == "OK":

#save converted format file from response

outfilename = "c:/temp/" + fileName + "." + ".zip"

with open(outfilename, 'wb') as f:

for chunk in response.InputStream:

f.write(chunk)

We are sorry for the inconvenience.

Best Regards,

Is there any Updates ?

Hi Bharani,


Thanks for your patience. We have tested your sample code with shared PDF document and unable to notice reported exception. Please find attached working code,along with the results, try it and share the results. Please double check whether your have access to the source PDF document on the system.

P.S: Add your App SID and key in shared code.

Best Regards,