def testPostDocumentSaveAs(self): try: response = self.storageApi.PutCreate( 'SampleWordDocument.docx', './data/SampleWordDocument.docx') saveOptions = SaveOptionsData.SaveOptionsData() saveOptions.FileName = 'SampleWordDocument.pdf' saveOptions.SaveFormat = 'pdf' response = self.wordsApi.PostDocumentSaveAs( 'SampleWordDocument.docx', saveOptions) self.assertEqual(response.Status, 'OK') self.assertIsInstance(response, SaveResponse.SaveResponse) except ApiException as ex: print "Exception" print "Code: " + str(ex.code) print "Mesage: " + ex.message raise ex
def testPostLoadWebDocument(self): try: loadWebDocumentData = LoadWebDocumentData.LoadWebDocumentData() loadWebDocumentData.LoadingDocumentUrl = 'http://google.com' saveOptions = SaveOptionsData.SaveOptionsData() saveOptions.SaveFormat = 'doc' saveOptions.FileName = 'google.doc' loadWebDocumentData.SaveOptions = saveOptions response = self.wordsApi.PostLoadWebDocument(loadWebDocumentData) self.assertEqual(response.Status, 'OK') self.assertIsInstance(response, SaveResponse.SaveResponse) except ApiException as ex: print "Exception" print "Code: " + str(ex.code) print "Mesage: " + ex.message raise ex
try: #Instantiate Aspose Storage API SDK storageapiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, debug = True) storageApi = StorageApi(storageapiClient) #Instantiate Aspose Words API SDK apiClient = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, debug = True) wordsApi = WordsApi(apiClient); #set input file name filename = "SampleWordDocument.docx" format = "pdf" outfilename = "SampleWordDocumentOutput.pdf" body = SaveOptionsData.SaveOptionsData() body.FileName = outfilename body.SaveFormat = "pdf" # invoke Aspose.Words Cloud SDK API to save document to required format response = wordsApi.PostDocumentSaveAs(filename, body) if(response.Status == 'OK'): outputfilename = response.SaveResult.DestDocument.Href; response = storageApi.GetDownload(Path= outputfilename) outfilename = "c:/temp/" + outputfilename with open(outfilename, 'wb') as f: for chunk in response.InputStream: f.write(chunk) except ApiException as ex:
try: #Instantiate Aspose Storage API SDK storage_apiClient = asposestoragecloud.ApiClient.ApiClient( apiKey, appSid, True) storageApi = StorageApi(storage_apiClient) #Instantiate Aspose Words API SDK api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True) wordsApi = WordsApi(api_client) #set output file name filename = "WebPageConverterExample.doc" loadWebDocumentData = LoadWebDocumentData.LoadWebDocumentData() loadWebDocumentData.LoadingDocumentUrl = "http://www.aspose.com/corporate/default.aspx" saveOptionsData = SaveOptionsData.SaveOptionsData() saveOptionsData.FileName = filename saveOptionsData.SaveFormat = "doc" loadWebDocumentData.SaveOptions = saveOptionsData #invoke Aspose.Words Cloud SDK API to convert live web page into words document response = wordsApi.PostLoadWebDocument(body=loadWebDocumentData) if (response.Status == 'OK'): print "Document has been generated successfully" #download output document from storage server response = storageApi.GetDownload(Path=filename) outfilename = "c:/temp/" + filename with open(outfilename, 'wb') as f: for chunk in response.InputStream: f.write(chunk)